【发布时间】:2019-08-09 18:49:41
【问题描述】:
我有这个组件:InputField.vue
<template>
<div class="w-full">
<label class="sr-only" :for="name"></label>
<input
:placeholder="label"
:name="name"
class="border-b border-black w-full appearance-none w-full py-4 px-3 text-grey-darker leading-tight"
/>
</div>
</template>
<script>
export default {
props: {
label: {
type: String,
required: true,
default: 'label', /* <--------- Always prints default */
},
name: {
type: String,
required: true,
default: 'name', /* <--------- Always prints default */
},
},
data() {
return {}
},
}
</script>
这就是我从另一个组件中使用它的方式:
<inputField :label="Hola" :name="nombre" />
但label 和name 始终是组件声明中定义的默认值,
知道我错过了什么吗?
【问题讨论】:
-
嗨,托尼,看看我的回答,希望够清楚,你几乎没看错,只是语法而已。
标签: vue.js properties components