Vuejs2 VUEJS-为什么会得到:未捕获的TypeError:x27的右侧;instanceof';?
我在vue.js中遇到了关于“未捕获类型错误:'instanceof'右侧不是对象”的问题 我使用的是Vue 2.2.1版本,下面是我的代码片段,我从中得到了这个问题Vuejs2 VUEJS-为什么会得到:未捕获的TypeError:x27的右侧;instanceof';?,vuejs2,vue-component,Vuejs2,Vue Component,我在vue.js中遇到了关于“未捕获类型错误:'instanceof'右侧不是对象”的问题 我使用的是Vue 2.2.1版本,下面是我的代码片段,我从中得到了这个问题 Vue.component('componentName', { 'template': ``, props: { contentTypeUid: { type: 'string', required: false }, limit: { type: 'number', require
Vue.component('componentName', {
'template': ``,
props: {
contentTypeUid: {
type: 'string',
required: false
},
limit: {
type: 'number',
required: false,
default: 10
}
},
......
});
虽然if不是上面提到的,但我想使用上面的格式,因为我需要在道具上指定一些验证和默认值
Vue.component('componentName', {
'template': ``,
props: ["contentTypeUid", "limit"],
......
});
谢谢。使用:
props: {
contentTypeUid: {
type: String, // not 'string'
required: false
},
limit: {
type: Number, // not 'number'
required: false,
default: 10
}
},
发生此错误的另一个原因是:
props: {
prop_id: {
required: true
},
title: 'Not specified'
},
因此,您需要将其更改为:
props: {
prop_id: {
required: true
},
title: {
default: 'Not specified'
}
},