代码之家  ›  专栏  ›  技术社区  ›  sonoerin

正在获取分配给空的typerror?

  •  0
  • sonoerin  · 技术社区  · 7 年前

    使用Nativescript vue(~2.0.0)并通过此集成vue路由器(^3.0.6) tutorial ,我得到一个错误:

    file:///app/bundle.js:876:7:js错误类型错误:试图分配 只读属性。(CoreFoundation)***由于 “未捕获异常”NativeScript遇到致命错误:TypeError: 试图分配给只读属性。在1

    ./router/index.js@文件:///app/bundle.js:924:34 3
    网页包要求
    ./app.js@文件:///app/bundle.js:653:34 6
    @文件:///app/bundle.js:76:34 7 checkDeferredModules@file:///app/bundle.js:45:42 8
    @文件:///app/bundle.js:149:389
    匿名@file:///app/bundle.js:150:12 10求值@[本机代码]11 需要@[native code]14匿名@file:///app/starter.js:2:8 15 求值@[本机代码]16模块求值@[本机代码]17

    我有这个密码: 应用程序js:

    import Vue from "nativescript-vue";
    import router from '~/router';
    
    new Vue({
        router
    }).$start();
    

    import Vue from 'nativescript-vue';
    import VueRouter from 'vue-router';
    
    Vue.use(VueRouter);
    
    import Startup from '../components/Startup'
    import OfficeHome from '../components/Office/OfficeHome'
    
    const routes = [
      { path: '/home', component: Startup },
      { path: '/officeHome', component: OfficeHome },
      {path: '*', redirect: '/home'}
    ];
    
    const router = new VueRouter({
      routes
    });
    
    router.replace('/home');
    module.exports = router;
    

    这些页面基本上是:

    <template>
        <Page class="page">
            <ActionBar title="testing " class="action-bar" icon="" />
    
            <FlexboxLayout flexDirection="column" justifyContent="center" class="full-height">
                <!--Add your page content here-->
                <StackLayout class="container">
                    <FlexboxLayout alignItems="center">
                        <Label textWrap="true" text="test tech"
                               class="intro-text" />
                    </FlexboxLayout>
                    <StackLayout>
                        <Button class="btn btn-primary" @tap="$router.push('/home')">Home</Button>
                        <Button class="btn btn-primary" @tap="$router.push('/officeHome')">Office</Button>
                    </StackLayout>
                </StackLayout>
            </FlexboxLayout>
        </Page>
    </template>
    
    <script>
    </script>
    

    {
      "nativescript": {
        "id": "com.company.me",
        "tns-android": {
          "version": "5.0.0"
        },
        "tns-ios": {
          "version": "5.0.0"
        }
      },
      "description": "NativeScript Application",
      "license": "SEE LICENSE IN <your-license-filename>",
      "repository": "<fill-your-repository-here>",
      "dependencies": {
        "axios": "^0.18.0",
        "nativescript-dev-appconfig": "^1.0.2",
        "nativescript-nfc": "^3.0.1",
        "nativescript-theme-core": "~1.0.4",
        "nativescript-vue": "~2.0.0",
        "nativescript-vue-devtools": "^1.1.0",
        "node-uuid": "^1.4.8",
        "tns-core-modules": "~5.0.0",
        "vue-router": "^3.0.6",
        "vuex": "^3.0.1"
      },
      "devDependencies": {
        "@babel/core": "~7.1.0",
        "@babel/preset-env": "~7.1.0",
        "babel-loader": "~8.0.0",
        "nativescript-dev-webpack": "~0.17.0",
        "nativescript-vue-template-compiler": "~2.0.0",
        "node-sass": "~4.9.0",
        "vue-devtools": "^5.0.0-beta.1",
        "vue-loader": "~15.4.0",
        "webpack-synchronizable-shell-plugin": "0.0.7",
        "optimize-css-assets-webpack-plugin": "^3.2.0",
        "winston-color": "^1.0.0",
        "nativescript-vue-target": "^0.1.0",
        "nativescript-vue-externals": "^0.2.0"
      }
    }
    

    作为JS/NativeScript的新手,我不确定这个错误发生在哪里。我认为这个错误表示router/index.js,除了没有第34行。

    知道在哪里分配什么吗?

    0 回复  |  直到 7 年前