[英]Uncaught TypeError: Cannot read properties of undefined (reading 'extend') after upgrade vue to 3.x
Today I upgrade my google chrome extension vue version to 3.x, when run the app, the google chrome extension popup console shows error like this:今天我将我的 google chrome 扩展 vue 版本升级到 3.x,当运行应用程序时,google chrome 扩展弹出控制台显示如下错误:
commons1.js:13392 Uncaught TypeError: Cannot read properties of undefined (reading 'extend')
at Object../src/public/widget/index.js (commons1.js:13392)
at __webpack_require__ (popup.js:23)
at Object../src/popup/st.js (commons1.js:12725)
at __webpack_require__ (popup.js:23)
at Object../src/popup/app.js (commons1.js:12543)
at __webpack_require__ (popup.js:23)
at Object../src/popup/index.js (commons1.js:12687)
at __webpack_require__ (popup.js:23)
at popup.js:163
at Function.__webpack_require__.O (popup.js:57)
I am searching from inte.net that knows that seems vue 3 did not support using extend to load third party component .我正在从知道似乎vue 3 不支持使用扩展加载第三方组件的 inte.net 进行搜索。 what should I do to fix this problem?
我应该怎么做才能解决这个问题? Is it possible using the vue 3 code to do the same thing as vue 2?
是否可以使用 vue 3 代码来执行与 vue 2 相同的操作? how to tweak my vue 2 code?
如何调整我的 Vue 2 代码? This is the vue 2 code with extend looks like:
这是带有 extend 的 vue 2 代码,如下所示:
export default Vue.extend( {
template ,
data : ()=>({})
})
In vue 3 there's no exported member called Vue
, the right code that's equivalent for Vue.extend
is:在 vue 3 中没有名为
Vue
的导出成员,与Vue.extend
等效的正确代码是:
import { defineComponent } from 'vue';
export default defineComponent({
template ,
data : ()=>({})
})
Do like the dumentation :不喜欢dumentation :
main.js:主.js:
import Vue from 'vue'
import App from './App.vue'
import vuetify from '@/plugins/vuetify' // path to vuetify export
Vue.config.productionTip = false
new Vue({
vuetify,
render: h => h(App),
}).$mount('#app')
Create a file in src/plugins/vuetify.js with this:使用以下命令在 src/plugins/vuetify.js 中创建一个文件:
import Vue from 'vue'
import Vuetify from 'vuetify'
import 'vuetify/dist/vuetify.min.css'
Vue.use(Vuetify)
const opts = {}
export default new Vuetify(opts)
If you got this error for toastr library this solution for u:如果您在 toastr 库中遇到此错误,则此解决方案适用于您:
The same issue got resolved for me when i have imported jQuery before importing toastr library in my build json.当我在我的构建 json 中导入 toastr 库之前导入 jQuery时,同样的问题为我解决了。
So please import toastr library after jQuery
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.