我正在设置一个新的vue项目,路由器在控制台中抛出以下错误消息:
“vue-路由器未能解析异步组件默认值: ReferenceError: jQuery未定义
路由导航过程中路由器未登录错误:
ReferenceError: jQuery未定义“
我检查了是否在jQuery文件中导入了*.vue :就是这样。另外,我还通过npm重新安装了jQuery包。
公式1.:
<script>
import JQuery from 'jquery'
let $ = JQuery;
some code...
</script>router.js:
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
Vue.use(Router)
export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */
'./views/About.vue')
},
{
path: '/formular1',
name: 'formular1',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "formular1" */
'./views/Formular1.vue')
}
]
})我希望执行vue文件,但却出现了错误。
所有的帮助都是感激的。
编辑:formar1.vue:
<template>
<div>
<table>
<thead>
<th v-for="data in datas" :key="data.ED_KBEVLID"></th>
</thead>
<tbody>
</tbody>
</table>
</div>
</template>
<script>
import jQuery from 'jquery'
let $ = jQuery;
export default {
name: 'Formular1',
data: function () {
return {
datas: [],
}
},
methods: {
lade_daten: function () {
let vm = this;
$.getJSON("/api/call_evm.php", function(result){
vm.datas = result;
});
}
},
mounted(){
this.lade_daten();
}
}
</script>发布于 2019-01-29 11:32:14
jQuery不同于JQuery,可能这就是问题所在。
检查代码中的任何地方是否使用相同的字母大小写以相同的方式编写。
https://stackoverflow.com/questions/54419717
复制相似问题