Vue.js不会呈现表单的元素

时间:2018-07-23 12:46:17

标签: vue.js vue-component

我是Vue.js的新手。我想创建一个多步骤注册组件。 这将是带有“下一步”和“上一步”按钮的2种形式。

我创建了一个模板。不幸的是,Vue.js无法呈现我的表单(输入和按钮)。它显示了唯一带有背景和文本“ Debug”的div 我的其他组件正常工作,但是这有麻烦。

<template>
  <div class="l-signup-container">
    <div class="l-signup">
      <v-form v-model="validSignUp">
        <div v-if="step === 1">
          <h1>1 шаг</h1>
          <v-text-field label="Полное Имя"
                        v-model="newUser.name"
                        :rules="rules"
                        required
                        color="light-blue lighten-1">
          </v-text-field>

          <v-text-field label="Название Организации"
                        v-model="newUser.company"
                        :rules="rules"
                        required
                        color="light-blue lighten-1">
          </v-text-field>

          <v-text-field label="Адрес электронной почты"
                        v-model="newUser.email"
                        :rules="rules"
                        required
                        color="light-blue lighten-1">
          </v-text-field>

          <v-text-field label="Пароль"
                        v-model="newUser.password"
                        prepend-icon="lock"
                        :rules="rules"
                        :append-icon="signUpPasswordVisible ? 'visibility' : 'visibility_off'"
                        :append-icon-cb="() => (signUpPasswordVisible = !signUpPasswordVisible)"
                        :type="signUpPasswordVisible ? 'text' : 'password'"
                        color="light-blue lighten-1"
                        required>
          </v-text-field>
          <v-btn block color="light-blue lighten-1" @click.prevent="next()">Дальше</v-btn>
        </div>

        <div v-if="step === 2">
          <h1>Пригласить сотрудников</h1>
          <v-text-field label="Адрес электронной почты"
                        v-model="newUser.email"
                        :rules="rules"
                        required
                        color="light-blue lighten-1">
          </v-text-field>
          <v-text-field label="Адрес электронной почты"
                        v-model="newUser.email"
                        :rules="rules"
                        required
                        color="light-blue lighten-1">
          </v-text-field>
          <v-text-field label="Адрес электронной почты"
                        v-model="newUser.email"
                        :rules="rules"
                        required
                        color="light-blue lighten-1">
          </v-text-field>

          <v-btn block color="light-blue lighten-1" @click.prevent="prev()">Назад</v-btn>
          <v-btn block color="light-blue lighten-1" @click.native="submitSignUp()">Начать работу</v-btn>

        </div>

      </v-form>
    </div>
    <br/><br/>Debug: {{registration}}
  </div>

</template>

<script>
import TestReg from '@/components/pages/TestReg'
export default {
  data () {
    return {
      validSignUp: false,
      signUpPasswordVisible: false,
      rules: [ (value) => !!value || 'This field is required' ],
      newUser: {
        name: '',
        email: '',
        company: '',
        password: ''
      },
      message: ''
    }
  },
  methods: {
    prev () {
      this.step--
    },
    next () {
      this.step++
    },
    submitSignUp () {
      TestReg.signup(this, this.newUser, '/')
    }
  }
}
</script>

<style lang="scss">
  @import "./../../../assets/styles";
  .l-signup {
    background-color: $background-color;
    padding: 15px;
    margin: 45px auto;
    min-width: 272px;
    max-width: 320px;
    animation: slideInFromLeft 1s forwards ease;
  }
</style>

1 个答案:

答案 0 :(得分:0)

我试图复制您的组件。我猜您必须在data属性中定义一些变量:

data () {
    return {
      validSignUp: false,
      signUpPasswordVisible: false,
      rules: [ (value) => !!value || 'This field is required' ],
      step: 1,
      registration: '',
      //...
    }
}