Vue.js 3: props type validation with custom type
export default defineComponent({
props: {
person: {
type: Object as PropType<Person>,
required: true
}
}
})
export default defineComponent({
props: {
person: {
type: Object as PropType<Person>,
required: true
}
}
})
unionapp vue3 vite cli 项目配置px转rpx
const axiosInstance = axios.create({
withCredentials: true,
})
const app = createApp()
👇
app.config.globalProperties.$axios = { ...axiosInstance }
computed property classes should declare a type, like this
computed: {
classes ():any {
return {
"navbar--on-scroll": this.onScroll,
"navbar--active": this.navbarActive
}
}
}
在 script
中增加
import { defineComponent } from 'vue'
export default { ... }
的形式改成 export default defineComponent({ ... })
的形式即可在 Vue 3 中,beforeDestroy 和destroy hooks 被替换为 beforeUnmount
和 unmounted