vue3设置路由hash模式
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
const router = createRouter({
history: createWebHashHistory(),
routes
})
vue3设置路由history模式
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
const router = createRouter({
history: createWebHistory(),
routes
})
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
})
module.exports = {
publicPath:'./',
devServer: {
historyApiFallback: true
}
}
穿透工具 https://github.com/oldj/SwitchHosts/releases/tag/v4.1.2
vue3 reactive定义数组或者对象内部的数组在ts下如何赋值?
const data = reactive({
list: [] as any[] // 属性需要做类型断言处理
});
data.list.push(sclist);//success
vue3表单校验
import type { FormInstance, FormRules } from 'element-plus'
const ruleFormRef = ref<FormInstance>()
return {ruleFormRef}
submitForm(submitForm)
const submitForm = async (formEl: FormInstance | undefined) => {
if (!formEl) return
await formEl.validate((valid, fields) => {
if (valid) {
console.log('submit!')
} else {
console.log('error submit!', fields)
}
})
}
vue3试用ref获取元素(注意不要有v-if)
<video ref="videoRef" :src="realFileUrl" preload></video>
videoRef需要return出去
return{
videoRef,
}
const videoRef = ref()
const playVideo = ()=>{
console.log('是的',videoRef)
videoRef.value.play()
}