<script setup lang="ts">
import { reactive, ref } from 'vue';
import type { FormInst, FormRules } from 'naive-ui';
import { EnumLoginModule } from '@/enum';
import { useAuthStore } from '@/store';
import { useRouterPush } from '@/composables';
import { formRules } from '@/utils';
import { OtherAccount } from './components';
const auth = useAuthStore();
const { login } = useAuthStore();
const { toLoginModule } = useRouterPush();
const formRef = ref<HTMLElement & FormInst>();
const model = reactive({
userName: 'Soybean',
password: 'soybean123'
});
const rules: FormRules = {
password: formRules.pwd
};
const rememberMe = ref(false);
async function handleSubmit() {
await formRef.value?.validate();
const { userName, password } = model;
login(userName, password);
}
function handleLoginOtherAccount(param: { userName: string; password: string }) {
const { userName, password } = param;
login(userName, password);
}
</script>
<style scoped></style>
Footer
© 2022 GitHub, Inc.
Footer navigation
Terms
Privacy
这段代码不是太懂,求大佬们帮解释下
我看登陆是调用 handleSubmit,handleSubmit是await formRef,这个 formRef 的值ref<HTMLElement & FormInst>();是啥意思?
const { login } = useAuthStore();这个也不是很懂,我看也没有 import login 函数啊,这行代码的意思是 把 useAuthStore 的返回值 赋给 login 函数?