LoginSignup
0
0

More than 5 years have passed since last update.

単一ファイルコンポーネントで使用するときのvue-validator

Last updated at Posted at 2016-11-04

v2.1.6を使用。
v2.1.7だとビルドミス?っているらしく、サンプル含め動作しなかった。

まず症状として、単一ファイルコンポーネントでvue-validatorを使用すると動作しない。
エラーを見ると内部で保持しているvalidateに使用する関数がうまく参照側へ引き継げていないよう。

完全なFixではないと思うが
2行ほどコードを足すとエラーは回避できたようなので、そのコードを置いておく。


var BaseValidation = function () {
  function BaseValidation(field, model, vm, el, scope, validator, filters, detectBlur, detectChange) {
    babelHelpers.classCallCheck(this, BaseValidation);

    this.field = field;
    this.touched = false;
    this.dirty = false;
    this.modified = false;

    this._modified = false;
    this._model = model;
    this._filters = filters;
    this._validator = validator;
    this._vm = vm;
    this._el = el;
    this._forScope = scope;
    this._init = this._getValue(el);
    this._validators = {};
    this._detectBlur = detectBlur;
    this._detectChange = detectChange;
    this._classes = {};

    // validatorsが正常に引き継がれないのでextendする
    var extend = exports$1.Vue.util.extend;
    this._vm.$options.validators = extend(this._vm.$options.validators || Object.create(null), exports$1.Vue.options.validators);
  }

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0