Hbuilderx 执行“运行到浏览器” 就报如下错误:
正在热重载...
11:28:06.197 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js):
11:28:06.197 语法错误: Unexpected token (1:229)
11:28:06.212 at components\nav-tab\nav-tab.vue:1
这个问题如何解决?Hbuilder x 的版本:3.2.9.20210927
nav-tab.vue 的代码如下:
<template>
<view class="mod-nav-tab uni-inline-item">
<template v-for="(item,idx) in arrTabs">
<view :key="idx" :style="'width: '+750/arrTabs.length+'rpx;'+(idx===arrTabs.length-1?'':('margin-right:'+seprate+';'))" :class="[selectIndex===idx?'on':(hideLine?'':'un')],'tab'" @click="tabAction(idx)">
<text :class="[hideLine?'txt-no':'text']" >{{item}}</text>
</view>
</template>
</view>
</template>
<script>
export default {
data() {
return {
selectIndex: 0
};
},
props: {
arrTabs: {
type:Array,
default(){
return[];
}
},
select: {
type: Number,
default () {
return 0;
}
},
hideLine:{
type:Boolean,
default:false
},
seprate:{
type:String,
default:'0'
}
},
onShow() {
},
watch: {
select(newData,old) {
this.selectIndex = newData;
}
},
methods: {
tabAction: function(idx) {
this.selectIndex = idx
this.$emit('tabchange',{index:idx})
}
}
}
</script>
这样的错误如何解决?
j***@163.com (作者)
把这部分 :class="[selectIndex===idx?'on':(hideLine?'':'un')],'tab'" 改成 :class="[selectIndex===idx?'on':(hideLine?'':'un'),'tab']",这个语法出错就解决。一般出现这个错误,应该都是自己的问题。
2021-10-24 14:44