Element

Element 提 bug 模板

by leopoldthecuber

HTML

<script src="//unpkg.com/[email protected]/dist/vue.js"></script>
<script src="//unpkg.com/[email protected]/lib/index.js"></script>

<div id="app"></div>

CSS

@import url("//unpkg.com/[email protected]/lib/theme-default/index.css");

JavaScript

var Main = {
  methods: {
    handleChange(val) {
      console.log('Changed to ', val) 
    }
  },
  mounted() {
    setTimeout(() => {
      this.value = '选项2'
    }, 2000)
  },
  watch: {
    value(val, oldVal) {
      if (oldVal) {
        console.log(val)
      }
    }
  },
  data() {
    return {
      value: '',
      options: [{
          value: '选项1',
          label: '黄金糕'
        }, {
          value: '选项2',
          label: '双皮奶'
        }, {
          value: '选项3',
          label: '蚵仔煎'
        }, {
          value: '选项4',
          label: '龙须面'
        }, {
          value: '选项5',
          label: '北京烤鸭'
        }]
    }
  },
  template: `
    <el-select v-model="value">
      <el-option
        v-for="item in options"
        :label="item.label"
        :value="item.value">
      </el-option>
  	</el-select>
  `
}

new Vue({
  el: '#app',
  render: h => h(Main)
})