For the little tricks vue binding model and set of values inside get

Look at an example:

 

template里边内容:
<el-form-item label="导航条类型">
      <el-radio-group v-model="navbarLayoutType">
        <el-radio label="default" border>default</el-radio>
        <el-radio label="inverse" border>inverse</el-radio>
      </el-radio-group>
    </el-form-item>

script里边内容:
computed: {
      navbarLayoutType: {
        get () { return this.$store.state.common.navbarLayoutType },
        set (val) {
          debugger
          this.$store.commit('common/updateNavbarLayoutType', val) }
      },

  Click to get this side is that the value of the acquired radio, set inside the val is get the value in, then click on the first now is the default

Guess you like

Origin www.cnblogs.com/sweeeper/p/11198930.html