首页 > 解决方案 > 在 Typescript 支持下启动新的 nativescript-vue 项目的正确方法是什么?

问题描述

我希望能够在 Vue 实例方法中使用 Typescript,如nativescript-vue.org的博客页面中所述

当我创建一个新的 nativescript-vue 项目时vue init nativescript-vue/vue-cli-template <project-name>,调试屏幕中会出现以下警告。

tns debug android

总是给出以下错误行...

JS: '{NSVue (Vue: 2.6.10 | NSVue: 2.5.0)} -> CreateElement(NativePage)'
JS: '{NSVue (Vue: 2.6.10 | NSVue: 2.5.0)} -> CreateElement(NativeActionBar)'
JS: '{NSVue (Vue: 2.6.10 | NSVue: 2.5.0)} -> AppendChild(ElementNode(nativepage), ElementNode(nativeactionbar))'
JS: '{NSVue (Vue: 2.6.10 | NSVue: 2.5.0)} -> CreateElement(nativegridlayout)'
JS: '{NSVue (Vue: 2.6.10 | NSVue: 2.5.0)} -> CreateElement(nativelabel)'
JS: '{NSVue (Vue: 2.6.10 | NSVue: 2.5.0)} -> AppendChild(ElementNode(nativegridlayout), ElementNode(nativelabel))'
JS: '{NSVue (Vue: 2.6.10 | NSVue: 2.5.0)} -> AppendChild(ElementNode(nativepage), ElementNode(nativegridlayout))'
JS: '{NSVue (Vue: 2.6.10 | NSVue: 2.5.0)} -> AppendChild(ElementNode(nativeframe), ElementNode(nativepage))'

这些以 JS:... 行开头的样板警告是什么?


更新

JS 错误行在我添加后开始@vue/devtools nativescript-toasty nativescript-socketio nativescript-vue-devtools

即使我删除它们,控制台警告仍然存在。


我想知道,如果快速启动页面已过时?由于Vue-cli-template在过去 30 天内没有得到任何更新。

注意:创建的项目tns create 不会出现此类错误。只有 vue-cli-template 有警告。

标签: typescriptnativescriptvue-clinativescript-vuevue-devtools

解决方案


日志中提到的行既不是错误也不是警告——它们是渲染器日志。

这些可以通过关闭

Vue.config.silent = true

// Since NativeScript-Vue 2.5.0-alpha.3 the renderer logs
// can be disabled keeping other useful logs intact via
Vue.config.suppressRenderLogs = false

app.jsmain.js(取决于使用的模板)。


推荐阅读