美文网首页
vue 粘贴板

vue 粘贴板

作者: writeSpace | 来源:发表于2022-07-22 17:31 被阅读0次

    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 : "",
    

    相关文章

      网友评论

          本文标题:vue 粘贴板

          本文链接:https://www.haomeiwen.com/subject/tgamirtx.html