【问题标题】:Uncaught TypeError: Vue.use is not a function未捕获的 TypeError:Vue.use 不是函数
【发布时间】:2021-03-13 04:38:57
【问题描述】:

我对 VueJS 比较陌生,现在我正在尝试替换

 <script src="https://cdn.jsdelivr.net/npm/vue@2.6/dist/vue.min.js"></script>

通过

<script src="https://unpkg.com/vue@next"></script>

问题是之前的工作代码在此更改后被破坏:

<script>
    window.addEventListener('load', () => {
        const defaultOptions = {
            position: 'bottom-center'
        }
        Vue.use(Toasted, defaultOptions) # The error arises here
    });

</script>

我遇到了

未捕获的类型错误:Vue.use 不是函数

我在这里做错了什么?

更新: 我暂时不使用 webpack。没有 webpack 是否可以做到这一点?

【问题讨论】:

标签: html vue.js vuejs3 vue-composition-api


【解决方案1】:

@next 指的是具有不同语法的 vue 3,假设 Toasted 插件与 vue 3 兼容,您应该这样做:

<script>
    window.addEventListener('load', () => {
        const defaultOptions = {
            position: 'bottom-center'
        }
        Vue.createApp({}).use(Toasted, defaultOptions) 
    });

</script>

【讨论】:

    猜你喜欢
    • 2017-07-20
    • 2019-09-26
    • 2015-12-29
    • 2021-09-09
    • 2017-07-31
    • 2016-11-02
    • 2016-08-07
    • 2022-01-25
    • 2016-11-21
    相关资源
    最近更新 更多