Laravel刀片通过cdn urls在刀片文件中进行验证

时间:2018-02-26 14:59:38

标签: laravel vue.js vee-validate

我在Laravel刀片中插入了cdn中的vue.js和vee-validate.js文件。 之后在脚本标记中插入了Vue.use(VeeValidate);

在此步骤之后,我(从此步骤开始)。最后我在脚本标签中有vue obj进行验证:

new Vue({
    el: '#app',
    created() {
        this.$validator.extend('bacon', {
              getMessage: field => {                      
                return `Field ${field} does not contain the word 'bacon'!`;
              },
              // Returns a boolean value
              validate: value => {                    
                return value.indexOf('bacon') !== -1;
              }
            });
      },
    methods: {
        validateBeforeSubmit(e){

              this.$validator.validateAll().then((result) => {
                if (result) {
                  alert('From Submitted!');
                  return;
                }
                alert(errors.length);
                alert('Correct them errors!');
              });
        }

    }
});

所有这些都需要在Laravel的刀片文件中完成。

0 个答案:

没有答案