ant vue的a-input-group里placeholder可以随着选择改变吗?

比如说选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, 是怎么回事呢?谢谢

阅读 5.4k
1 个回答
✓ 已被采纳新手上路,请多包涵

明白了,从method获取data别忘了加this

推荐问题