求大佬看看 laravel 使用 jetsteam (inertiajs) vue 的一个报错:app.js:63329 Uncaught ReferenceError: route is not defined

帖子列表 发布于 2021/01/02 21:09
阅读 309
收藏 0

开源之夏第三届火热来袭,高校学生参与赢万元奖金!>>>

# resource/js/app.js
require('./bootstrap');

require('moment');

// Vue.config.productionTip = false

import Vue from 'vue';
import { InertiaApp } from '@inertiajs/inertia-vue';
import { InertiaForm } from 'laravel-jetstream';
import PortalVue from 'portal-vue';
import App from './sample/demo1.vue';

Vue.use(InertiaApp);
Vue.use(InertiaForm);
Vue.use(PortalVue);
Vue.mixin({
    methods: {
        route: route
    }
});


const app0 = new Vue({
    el: '#app0',
    data: {
        num: 0,
        msg: 'this is app0',
        myHtml: '<h3>This is myHtml</h3>',
        keyClickUsername: '',
        keyClickPassword: '',
        myUrl: 'http://www.mydomain.com',
        isActive1: true,
        isActive2: false,
        myClassName3: 'cls3',
        myClassName4: 'cls4',
        hasMyClassName5: true,
        myClassArr: ['myClass1', 'myClass2'],
        myClassObj: {
            'myClass3':true
        },
        myColor: 'red',
        myFontSize: '3em',
        originStyles: { 'font-size': '2em' },
        overrideStyles: { 'font-size': '4em' }
    },
    methods: {
        addNum: function(event) {
            console.log(event.target.tagName)
        },
        multiplyNum: function (step1 = 1, step2 = 2, event) {
            this.num += step1 * step2
            console.log(event.target.tagName + event.target.innerHTML)
        },
        doLink1: function () {
            console.log('doLink1')
        },
        doLink2: function () {
            console.log('doLink2')
        },
        doKeyClick: function () {
            console.log('doKeyClick')
        }
    }
});

const app1 = new Vue({
    el: '#app1',
    components: { App }
});

const app = document.getElementById('app');

new Vue({
    render: (h) =>
        h(InertiaApp, {
            props: {
                initialPage: JSON.parse(app.dataset.page),
                resolveComponent: (name) => require(`./Pages/${name}`).default,
            },
        }),
}).$mount(app);

报了这个错:

加载中
0
w
wx2838

route 这个变量 还没有定义 

帖子列表
帖子列表
我 import 了 ziggy route 还是不行,报了 cannot read property undefined "irc.js" 等错误
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部