比如说选OPTION1的时候,里面的PLACE HOLDER是INPUT CONTENT, 选OPTION2的时候,我想换成别的内容。
试着用这个方法
<a-input-group compact >
<a-select defaultValue="option1" @change="handleChange">
<a-select-option value="option1" >option1</a-select-option>
<a-select-option value="option2" >option2</a-select-option>
</a-select>
<a-input :placeholder="selectedOption" />
</a-input-group>
然后
export default {
data () {
return {
selectedOption: '',
}
},
methods: {
handleChange(value) {
if(value==="option1"){
selectedOption = 'blahblah'
}
else{
selectedOption = 'hahahaha'
}
},
}
但是显示ReferenceError: selectedOption is not defined, 是怎么回事呢?谢谢
明白了,从method获取data别忘了加this