vue3 路由跳转
import { useRouter, useRoute } from "vue-router";
const { query } = useRoute();
const router = useRouter();
const route = useRoute();
router.push({
path: "/Page",
query: { id: id },
});
交互
引入
import Bridge from "../../../assets/js/bridge";///桥接
import { Device } from "../../../utils/utils";///判断设备类型
function clickItemHandler(obj: any) {
jsCallNativeHandler("openVod", obj.params);
}
/**
* @description: js调用原生方法
* @param {any} name 方法名字
* @param {any} data 参数
* @param {any} callback 完成回调
* @return {*}
*/
function jsCallNativeHandler(name: any, params: any) {
if (Device() == "ios") {
// (window as any).webkit.messageHandlers.openVod.postMessage(item.HK_URL, item.HK_TOKEN, sdkId)
Bridge.callhandler(name, params, (data: any) => {
});
} else if (Device() == "android") {
// (window as any).app.openVod(item.HK_URL, item.HK_TOKEN, sdkId);
}
}
Cookies 获取
1
import Cookies from "js-cookie";
/**
* 获取cookie 中的userId
*/
const userId = () => {
let userInfo: any = Cookies.get("key");
if (userInfo) {
return userInfo ? userInfo.userId : "";
}
return "";
};
2
import Cookies from "js-cookie";
let userInfo: any = Cookies.get("userInfo");
let userInfoObj = JSON.parse(userInfo);
mainId: userInfoObj ? userInfoObj.userId : "",
网友评论