VeeValidate 'required_if:' 规则

VeeValidate 'required_if:' rule

我使用了文档中的语法规则 required_ifvee-validate required_if rule 但它不起作用。

有人能给我指出正确的方向吗? 在我继续之前,我需要这个简单的 required_if 规则。

JSfiddle:

Vue.use(VeeValidate)

new Vue({
  el: '#app',
  data() {
    return {
      first: '',
      last: '',
    }
  },
  methods: {
    onSubmit() {
      this.$validator.validateAll()
        .then(result => {
          console.log(this)
          alert(result)
        })
    }
  }
})
@import url('https://unpkg.com/semantic-ui-css@2.2.9/semantic.css');
span.error {
  color: #9F3A38;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://unpkg.com/vee-validate@2.0.0-beta.25"></script>

<div id="app">
  <form class="ui form" @submit.prevent="onSubmit">
    <div class="field" :class="{error: errors.has('first')}">
      <label>Name</label>
      <input ref="firstName" type="text" name="first" placeholder="first" v-model="first">
      <span class="error" v-if="errors.has('first')">{{errors.first('first')}}</span>
    </div>
    <div class="field" :class="{error: errors.has('last')}">
      <label>Email</label>
      <input type="text" name="last" placeholder="last" v-validate="'required_if:firstName,test'" v-model="last">
      <span class="error" v-if="errors.has('last')">{{errors.first('last')}}</span>
    </div>
    <button type="submit" class="ui submit button">Submit</button>
  </form>
</div>

@Randy Casburn 指出我的正确 - 谢谢大佬!

问题出在版本上。我让它在这个例子下工作: my codesandbox

希望对大家有所帮助 ;-)