我正在尝试使用 Vue 将 html、js、css 文件转换为单个文件组件。我已经定义了“logininfo”形式,但命令行中出现一条错误消息,指出“logininfo”未定义。所以我无法检查登录表单是否正常工作。我已经在表单 ID 中定义了“登录信息”,并在将其导出到脚本文件时。
<template>
<div id="login">
<form id="logininfo" method="POST" @submit.prevent="onsubmit">
Email: <input v-model="email" type="email">
Password: <input v-model="password" type="password">
<button v-on:click="login" id="login">Login </button>
</form>
</div>
</template>
<script>
export default {
name: ‘logininfo’,
data() {
email: "",
password: ""
},
methods: {
login: function () {
var account = JSON.parse(localStorage.getItem('userdetails')).find(function(userdetails) {
return (logininfo.email === userdetails.email && logininfo.password === userdetails.password) ? userdetails : null;
});
if(account) {
window.location.href = "index.html?email=" + account.email;
} else {
alert("Email has not been identified. ");
}
}
}}