Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div id="app">
<el-button size="mini" @click="add">添加证件</el-button>
<el-button size="mini" @click="submit">提交时验证</el-button>
<el-form :model="user" ref="form" label-width="80px" size="mini">
      el-form-item 使用 :prop 绑定需要验证的数据
      :prop 的值是个字符串表达式,
      且最终访问的是el-form 所绑定对象中的数据
  <template v-for="(v1, i1) in user.credentials">
     :prop="'credentials[' + i1 + '].type'"
      <el-select v-model="v1.type" @change="selectChange(i1)">
        v-for="(v2, i2) in types"
     :prop="'credentials[' + i1 + '].value'"
      <el-input v-model="v1.value" @change="selectChange(i1)"></el-input>
              @import url("//unpkg.com/element-ui@2.4.11/lib/theme-chalk/index.css");
  width: 300px;
  border: 1px solid #eee;
  background-color: #f8f8f8;
#app form{
  margin-top: 22px;
  width: 200px;
              var Main = {
  data() {
    return {
      validateFail: false,
      user: {
        credentials: []
      types: [
          tid: '0',
          label: '身份证'
          tid: '1',
          label: '护照'
      typeRules: [
          required: true,
          message: '请输入身份证号',
          trigger: 'blur'
        {pattern: /(^\d{18}$)|(^\d{17}(\d|X|x)$)/,message:'身份证号格式错误',trigger:'blur'}
          required: true,
        {pattern: /^[a-zA-z](\d{8})$/,message:'护照格式错误',trigger:'blur'}]
      rules: {
        'type': [{
          required: true,
          message: '请选择证件',
          trigger: 'blur'
  methods: {
    add () {
        type: '',
        value: ''
      this.$refs.form.validate().then().catch(e => {
        this.validateFail = true;
      this.$nextTick(() => {
        this.$refs.form.validateField('credentials[' + i1 + '].type')
        this.$refs.form.validateField('credentials[' + i1 + '].value')
var Ctor = Vue.extend(Main);
var vm = new Ctor().$mount('#app');
window.vm = vm;

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.