1. 路由跳转
<script setup>
import { useRouter } from "vue-router";
const router = useRouter();
function toDetail() {
router.push({
path: "/detail",
});
}
</script>
2. 注册全局property
// main.js
import utils from "./utils/utils.js";
app.config.globalProperties.$utils = utils;
<script setup>
import { getCurrentInstance } from "vue";
const { proxy } = getCurrentInstance();
const $utils = proxy.$utils;
</script>
标签:const,记录,utils,vue3,使用,import,router,useRouter
From: https://www.cnblogs.com/lpkshuai/p/16942192.html