anonymous No title
No License JavaScript
2020年06月28日
Copy Clone
<template>
  <v-app id="inspire">
    <v-main>
      <v-container
        class="fill-height"
        fluid
      >
        <v-row
          align="center"
          justify="center"
        >
          <v-col
            cols="12"
            sm="8"
            md="4"
          >
            <v-card class="elevation-12">
              <v-toolbar
                color="primary"
                dark
                flat
              >
                <v-toolbar-title>Login form</v-toolbar-title>
                <v-spacer></v-spacer>
              </v-toolbar>
              <v-card-text>
                <v-form>
                  <v-text-field
                    label="Login"
                    name="login"
                    prepend-icon="mdi-account"
                    type="text"
                    v-model="email"
                  ></v-text-field>

                  <v-text-field
                    id="password"
                    label="Password"
                    name="password"
                    prepend-icon="mdi-lock"
                    type="password"
                    v-model="password"></v-text-field>
                </v-form>
              </v-card-text>
              <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn color="primary" @click="signUp">Sign up</v-btn>
                <v-btn color="primary" @click="signIn">Sign in</v-btn>
              </v-card-actions>
            </v-card>
          </v-col>
        </v-row>
      </v-container>
    </v-main>
  </v-app>
</template>

<script>
  export default {
    data(){
      return {
        email: "",
        password: "",
      }
    },
    methods: {
      singUp() {
        alert('Sign In')
        try {
          this.$store.dispatch('login/signUp', {
            email: this.email, 
            password: this.password
          })
        } catch(e) {
          alert('Error')
        }
      },
      signIn() {
        alert('Hello')
        try {
          this.$store.dispatch('login/signUp', {
            email: this.email, 
            password: this.password
          })
        } catch(e) {
          alert('Error')
        }
      }
    }
  }
</script>
<template>
  <v-app id="inspire">
    <v-main>
      <v-container
        class="fill-height"
        fluid
      >
        <v-row
          align="center"
          justify="center"
        >
          <v-col
            cols="12"
            sm="8"
            md="4"
          >
            <v-card class="elevation-12">
              <v-toolbar
                color="primary"
                dark
                flat
              >
                <v-toolbar-title>Login form</v-toolbar-title>
                <v-spacer></v-spacer>
              </v-toolbar>
              <v-card-text>
                <v-form>
                  <v-text-field
                    label="Login"
                    name="login"
                    prepend-icon="mdi-account"
                    type="text"
                    v-model="email"
                  ></v-text-field>

                  <v-text-field
                    id="password"
                    label="Password"
                    name="password"
                    prepend-icon="mdi-lock"
                    type="password"
                    v-model="password"></v-text-field>
                </v-form>
              </v-card-text>
              <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn color="primary" @click="signUp">Sign up</v-btn>
                <v-btn color="primary" @click="signIn">Sign in</v-btn>
              </v-card-actions>
            </v-card>
          </v-col>
        </v-row>
      </v-container>
    </v-main>
  </v-app>
</template>

<script>
  export default {
    data(){
      return {
        email: "",
        password: "",
      }
    },
    methods: {
      singUp() {
        alert('Sign In')
        try {
          this.$store.dispatch('login/signUp', {
            email: this.email, 
            password: this.password
          })
        } catch(e) {
          alert('Error')
        }
      },
      signIn() {
        alert('Hello')
        try {
          this.$store.dispatch('login/signUp', {
            email: this.email, 
            password: this.password
          })
        } catch(e) {
          alert('Error')
        }
      }
    }
  }
</script>
No one still commented. Please first comment.
Output