JSFiddle - React, Tailwind, and code Playground

by lmk123

HTML

<link rel="stylesheet" href="https://unpkg.com/[email protected]/lib/theme-default/index.css">
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
<script src="https://unpkg.com/[email protected]/lib/index.js"></script>

当 el-select 的 v-model 绑定一个对象的时候会有问题

<div id="app">
  <el-select
      v-model="value"
      filterable
      remote
      :remote-method="remoteMethod">
    <el-option
        v-for="item in options"
        :key="item.value" 
        :label="item.label"
        :value="item">
      <!-- value 绑定了数组里的对象本身 -->
    </el-option>
  </el-select>
</div>

JavaScript

new Vue({
  el: '#app',
  data: {
    value: null,
    options: []
  },
  methods: {
    remoteMethod: function() {
      var that = this
      setTimeout(function() {
        that.options = [{
          label: 'a',
          value: 'a'
        }]
      }, 200)
    }
  }
})