44 lines
1.1 KiB
Vue
44 lines
1.1 KiB
Vue
<template>
|
|
<div>
|
|
<p>hello home</p>
|
|
<p>Count: {{ tokenStore.count }}</p>
|
|
<button @click="tokenStore.increment">Increment</button>
|
|
<button @click="tokenStore.incrementAsync">Increment Async</button>
|
|
<router-link to="/about">About</router-link>
|
|
<el-alert
|
|
v-if="showAlert"
|
|
:title="alertTitle"
|
|
:type="alertType"
|
|
:description="alertDescription"
|
|
show-icon
|
|
/>
|
|
<div>
|
|
<el-button @click="fetchData" type="primary">main</el-button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from 'vue';
|
|
import request from '../api/request.js'
|
|
import { useTokenStore } from '../store/token.js';
|
|
|
|
const tokenStore=useTokenStore()
|
|
|
|
// 定义用于控制 el-alert 显示的变量
|
|
const showAlert = ref(false);
|
|
const alertTitle = ref('');
|
|
const alertType = ref('warning');
|
|
const alertDescription = ref('');
|
|
|
|
const fetchData = async()=>{
|
|
try {
|
|
const response=await request.get('/api/product')
|
|
console.log(response)
|
|
} catch (error) {
|
|
alertTitle.value = 'Error';
|
|
alertDescription.value = error.message;
|
|
showAlert.value = true;
|
|
}
|
|
}
|
|
</script> |