kazupon / vue-validator

:white_check_mark: Validator component for Vue.js
MIT License
2.19k stars 431 forks source link

vue-validator3.0.0-alpha.1 for vue2.0.3 #329

Closed xiyangjun closed 8 years ago

xiyangjun commented 8 years ago

[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. (found in root instance)

el:

     <validator name="validation" @valid="onValid" @invalid="onInvalid">
           <div class="alert alert-danger" v-show="errorMsg" v-html="errorMsg"></div>
            <form class="form-horizontal" id="data-panel-form"></form>
      </validator>
sqal commented 8 years ago

Did you installed the plugin?

import Vue from 'vue';
import VueValidator from 'vue-validator';

Vue.use(VueValidator);
xiyangjun commented 8 years ago

@sqal yes, I did this。

kazupon commented 8 years ago

validator custom element is deprecated for 3.0 You need to use validity wrap component. See the example: https://github.com/vuejs/vue-validator/blob/dev/examples/started/index.html

If you want to manage the validation results of validity wrap component, you need to use the validationwrap component. See the example: https://github.com/vuejs/vue-validator/blob/dev/examples/validation/index.html

chaegumi commented 8 years ago

no 3.0 document. 好难用。

heygambo commented 8 years ago

Hey I've tried that with the current alpha.1 version but I always get this:

[Vue warn]: Unknown custom element: <validity> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Even though I've installed the plugin as described:

import Vue from 'vue'
import VueValidator from 'vue-validator'
Vue.use(VueValidator)
chaegumi commented 8 years ago

You can use vee-validate.It can used for vuejs2.0.3.

heygambo commented 8 years ago

But I can also use vue-validator soon I hope

heygambo commented 8 years ago

hm I've found out that for some odd reason the index.js isn't the one that is tagged as alpha.1 in github. I don't know exactly why.

This is what I get from a yarn install

/* @flow */
import { warn } from './util'
import Config from './config'
import Asset from './asset'

function plugin (Vue: GlobalAPI, options: Object = {}) {
  if (plugin.installed) {
    warn('already installed.')
    return
  }

  Config(Vue)
  Asset(Vue)
}

plugin.version = '3.0.0-alpha.1'

export default plugin

if (typeof window !== 'undefined' && window.Vue) {
  window.Vue.use(plugin)
}

The components won't get installed with this script.

UPDATE: npm install will solve the issue. yarn has probably cached a version that I have downloaded from github directly.