SOURCE

console 命令行工具 X clear

                    
>
console
// var Main = {
//     data() {
//         return {
//             data: {
//                 name: 'test'
//             },
//             fits: ['fill', 'contain', 'cover', 'none', 'scale-down'],
//             url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'
//         }
//     },
//     methods: {
//         handle(e,data) {
//             // console.info(e, data)
//         }
//     }
// }
// var Ctor = Vue.extend(Main)
// new Ctor().$mount('#app')



import Schema from 'async-validator';
const descriptor = {
  name: {
    type: 'string',
    required: true,
    validator: (rule, value) => value === 'muji',
  },
  age: {
    type: 'number',
    asyncValidator: (rule, value) => {
      return new Promise((resolve, reject) => {
        if (value < 18) {
          reject('too young');  // reject with error message
        } else {
          resolve();
        }
      });
    },
  },
};
const validator = new Schema(descriptor);
validator.validate({ name: 'muji' }, (errors, fields) => {
  if (errors) {
    // validation failed, errors is an array of all errors
    // fields is an object keyed by field name with an array of
    // errors per field
    return handleErrors(errors, fields);
  }
  // validation passed
});

// PROMISE USAGE
validator.validate({ name: 'muji', age: 16 }).then(() => {
  // validation passed or without error message
}).catch(({ errors, fields }) => {
  return handleErrors(errors, fields);
});
<script src="//unpkg.com/vue@2/dist/vue.js">
</script>
<script src="//unpkg.com/element-ui@2.15.13/lib/index.js">
<script type="module" src="https://cdn.jsdelivr.net/npm/async-validator@4.2.5/+esm">
// import async-validator from "https://cdn.jsdelivr.net/npm/async-validator@4.2.5/+esm"
console.info("async-validator", async-validator)
</script>
<!-- <div id="app">
	<div class="demo-image">
		<div class="block" v-for="fit in fits" :key="fit">
			<span class="demonstration">{{ fit }}</span>
    <el-image
              draggable
      style="width: 100px; height: 100px"
      :src="url"
      :fit="fit"
       @dragstart="handle($event, data)"></el-image>
  </div>
</div>
</div> -->
@import url("//unpkg.com/element-ui@2.15.13/lib/theme-chalk/index.css");
#app {
    width: 500px;
    color: #fff;
}