var is a reserved word
1、错误描述PieChart.vue?a6c7:69 Uncaught (in promise) TypeError: Cannot read property '$el' of undefinedat PieChart.vue?a6c7:69client:162 [WDS] Errors while compiling. Reload prevented.errors@...
·
1、错误描述
PieChart.vue?a6c7:69 Uncaught (in promise) TypeError: Cannot read property '$el' of undefined
at PieChart.vue?a6c7:69
client:162 [WDS] Errors while compiling. Reload prevented.
errors
@ client:162
onmessage
@ socket.js:41
EventTarget.dispatchEvent
@ sockjs.js:170
(anonymous)
@ sockjs.js:887
SockJS._transportMessage
@ sockjs.js:885
EventEmitter.emit
@ sockjs.js:86
WebSocketTransport.ws.onmessage
@ sockjs.js:2961
client:168 ./src/views/dashboard/admin/components/PieChart.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib?cacheDirectory!./node_modules/vue-loader/lib??vue-loader-options!./src/views/dashboard/admin/components/PieChart.vue?vue&type=script&lang=js&)
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: F:/dojo/cdmn/vue-element-admin/src/views/dashboard/admin/components/PieChart.vue: var is a reserved word (49:4)
47 | },
48 | methods: {
> 49 | var that = this,
| ^
50 | initChart() {
51 | axios.get('/api/manage/common/cmp',{
52 |
params:{
errors @ client:168
onmessage @ socket.js:41
EventTarget.dispatchEvent @ sockjs.js:170
(anonymous) @ sockjs.js:887
SockJS._transportMessage @ sockjs.js:885
EventEmitter.emit @ sockjs.js:86
WebSocketTransport.ws.onmessage @ sockjs.js:2961
client:162 [WDS] Errors while compiling. Reload prevented.
errors @ client:162
onmessage @ socket.js:41
EventTarget.dispatchEvent @ sockjs.js:170
(anonymous) @ sockjs.js:887
SockJS._transportMessage @ sockjs.js:885
EventEmitter.emit @ sockjs.js:86
WebSocketTransport.ws.onmessage @ sockjs.js:2961
client:168 ./src/views/dashboard/admin/components/PieChart.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib?cacheDirectory!./node_modules/vue-loader/lib??vue-loader-options!./src/views/dashboard/admin/components/PieChart.vue?vue&type=script&lang=js&)
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: F:/dojo/cdmn/vue-element-admin/src/views/dashboard/admin/components/PieChart.vue: var is a reserved word (49:4)
47 | },
48 | methods: {
> 49 | var that = this,
| ^
50 | initChart() {
51 | axios.get('/api/manage/common/cmp',{
52 | params:{
2、错误原因
在vue.js中的methods,定义that=this,这个语句应该放在initChart方法中
methods: {
var that = this,
initChart(){
}
}
3、解决办法
调换变量定义的位置
methods: {
initChart(){
var that = this
}
}
更多推荐
已为社区贡献8条内容
所有评论(0)