首页 > 解决方案 > 无法读取 Quasar 2 中未定义的属性“原型”

问题描述

我在下面的代码任务的最后一行遇到错误,我该如何解决它。我正在使用 Quasar Framework 版本 2,Axios,它正在使用 Vue js 3,尝试在文件中导入 vue 并访问Vue.prototype实例,但它失败了。如果有任何解决方案,请帮我解决它。

Vue.prototype.$oauth = helper;"
import auth from "../store/auth";
import axios from 'axios';
import { axiosInstance } from "./axios";
import { jsonapiModule } from "jsonapi-vuex";


function isArrayOrString ( variable ) {
    if ( typeof variable === typeof [] || typeof variable === typeof "" )
    {
        return true;
    }
    return false;
}

export default ( { app, router, store, Vue } ) => {

    axios.interceptors.response.use(
        response => {
            return response;
        },
    );

    /**
     * Register i18n
     */
    // app.i18n.mergeLocaleMessage('en-us', enUS)

    /**
     * Register auth store
     */
    store.registerModule( "authentication", auth );

    store.registerModule(
        "jv",
        jsonapiModule( axios, { preserveJson: true } )
    );

    /**
     * Set authentication routes
     */
    let { routes } = router.options;
    let routeData = routes.find( r => r.path === "/auth" );
    routeData.children = [
        {
            path: "/login",
            name: "login",
            component: () => import( "pages/auth/Login" )
        }
    ];
    router.addRoute( [ routeData ] );

    // store.dispatch('auth/fetch').catch(() => {
    //     store.dispatch('auth/logout')
    // })

    var helper = {};
    helper.user = () => {
        return store.getters[ "authentication/fetch_access_token" ];
    };
    helper.user = () => {
        return store.getters[ "api/user" ];
    };
    // console.log( app.prototype );
    Vue.prototype.$oauth = helper;
};

标签: javascriptvuejs3quasar-framework

解决方案


推荐阅读