Используя Nativescript-vue (~ 2.0.0) и интегрируя vue-router (^ 3.0.6) через это учебное пособие , я получаю сообщение об ошибке:
file:///app/bundle.js:876:7: JS ERROR TypeError: Попытка присвоить свойству только для чтения.(CoreFoundation) *** Завершение работы приложения из-за необработанной исключительной ситуации 'NativeScript обнаружил фатальную ошибку: TypeError: Попытка присвоить свойству только для чтения.в 1
@file: ///app/bundle.js: 876: 7 2
./router/index.js@file:///app/bundle.js:924:34 3
webpack_require @ file: ///app/bundle.js: 76: 34 4 @file: ///app/bundle.js: 630: 84 5
./app.js@file:///app/bundle.js:653:34 6
webpack_require @ file: ///app/bundle.js: 76: 34 7 checkDeferredModules @ file: /// app / bundle.js: 45: 42 8
@file: ///app/bundle.js: 149: 38 9
анонимный @ file: ///app/bundle.js: 150: 12 10 оценить @ [собственный код] 11 moduleEvaluation @ [собственный код] 12 promReactionJob @ [собственный код] 13 требуют @ [собственный код] 14 анонимных @ file: ///app/starter.js: 2: 8 15 оценивать @ [собственный код] 16 moduleEvaluation @ [собственный код] 17 обещание реакцииJob @ [собственный код] ', причина:' (ноль) '
У меня есть этот код: app.js:
import Vue from "nativescript-vue";
import router from '~/router';
new Vue({
router
}).$start();
, который использует этот маршрутизатор/index.js:
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>
Не уверен, если это имеет значение, но вот мой package.json:
{
"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.
Любая идея, что назначается где?