组合式api 两种写法
写法1
<script lang="ts">
import { reactive } from 'vue'
import { getlist } from '../assets/api/test'
export default {
setup() {
const event = reactive({
name: '',
password: ''
})
const login = function() {
getlist().then(res => {
console.log(res)
})
}
return {
event,
login
}
}
}
</script>
写法2 写法2是一个简写
<script lang="ts" setup>
import { reactive } from 'vue'
import { getlist } from '../assets/api/test'
const event = reactive({
name: '',
password: ''
})
const login = function() {
getlist().then(res => {
console.log(res)
})
}
</script>