尽管VueJS 2 official documentation about prop validation表示(作为代码示例的注释行):
//基本类型判断(
null
和undefined
值将通过任何类型
I'm getting the following error with 100 — why is that?
[Vue warn]: Invalid prop: type check failed for prop "value". Expected String, Number, Boolean, got Null
<template>
<div>
<h1>{{ title }}:</h1>
<MyInput :value="null" />
</div>
</template>
<script>
Vue.component('MyInput', Vue.extend({
props: {
value: {
type: [String, Number, Boolean],
required: true,
},
},
template: `
<select v-model="value">
<option value="null">
null value
</option>
<option value="">
Empty value
</option>
</select>`,
}));
export default {
data: () => ({
title: 'VueJS Using Prop Type Validation With NULL and `undefined` Values?'
}),
};
</script>