以前,我曾在nativescript上从事过一些项目。但是现在,它已经更新了,我不知道为什么我的rad-list-view无法正常工作。
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:lv="nativescript-ui-listview" navigatingTo="onNavigatingTo" class="page">
...
...
<lv:RadListView row="1" items="{{ source }}">
<lv:RadListView.itemTemplate>
<GridLayout rows="*" columns="*">
<Label text="{{ name }}" textWrap="true" />
</GridLayout>
</lv:RadListView.itemTemplate>
</lv:RadListView>
...
...
source: [{
name: "Test",
}, {
name: "Test",
}, {
name: "Test",
}, {
name: "Test",
}, {
name: "Test",
}, {
name: "Test",
}, {
name: "Test",
}, {
name: "Test",
}, {
name: "Test",
}],
错误:-
System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onCreateViewHolder failed
System.err: TypeError: Cannot read property 'parse' of undefined
System.err:
System.err: StackTrace:
System.err: Frame: function:'push.../node_modules/nativescript-ui-listview/ui-listview.common.js.RadListView.resolveTemplateView', file:'file:///node_modules\nativescript-ui-listview\ui-listview.common.js:532:0
System.err: Frame: function:'push.../node_modules/nativescript-ui-listview/ui-listview.common.js.RadListView.getViewForViewType', file:'file:///node_modules\nativescript-ui-listview\ui-listview.common.js:579:0
System.err: Frame: function:'ListViewAdapter.onCreateViewHolder', file:'file:///node_modules\nativescript-ui-listview\ui-listview.js:129:0
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1109)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1089)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1081)
System.err: at com.telerik.widget.list.ListViewAdapter_vendor_1544_32_ListViewAdapter.onCreateViewHolder(Unknown Source:27)System.err: at com.telerik.widget.list.ListViewWrapperAdapter.onCreateViewHolder(ListViewWrapperAdapter.java:468)
System.err: at com.telerik.widget.list.ListViewWrapperAdapter.onCreateViewHolder(ListViewWrapperAdapter.java:20)
System.err: at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6794)
System.err: at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5975)
System.err: at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
System.err: at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
System.err: at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
System.err: at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
System.err: at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
System.err: at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
System.err: at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
System.err: at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
System.err: at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4194)
System.err: at com.telerik.widget.list.RadListView.onLayout(RadListView.java:600)
System.err: at android.view.View.layout(View.java:20871)
System.err: at android.view.ViewGroup.layout(ViewGroup.java:6268)
System.err: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
System.err: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
System.err: at android.view.View.layout(View.java:20871)
System.err: at android.view.ViewGroup.layout(ViewGroup.java:6268)
System.err: at org.nativescript.widgets.CommonLayoutParams.layoutChild(CommonLayoutParams.java:222)
System.err: at org.nativescript.widgets.GridLayout.onLayout(GridLayout.java:354)
System.err: at android.view.View.layout(View.java:20871)
System.err: at android.view.ViewGroup.layout(ViewGroup.java:6268)
System.err: at org.nativescript.widgets.CommonLayoutParams.layoutChild(CommonLayoutParams.java:222)
System.err: at org.nativescript.widgets.GridLayout.onLayout(GridLayout.java:354)
System.err: at android.view.View.layout(View.java:20871)
System.err: at android.view.ViewGroup.layout(ViewGroup.java:6268)
System.err: at org.nativescript.widgets.CommonLayoutParams.layoutChild(CommonLayoutParams.java:222)
System.err: at org.nativescript.widgets.ContentLayout.onLayout(ContentLayout.java:73)
System.err: at android.view.View.layout(View.java:20871)
System.err: at android.view.ViewGroup.layout(ViewGroup.java:6268)
System.err: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
System.err: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
System.err: at android.view.View.layout(View.java:20871)
System.err: at android.view.ViewGroup.layout(ViewGroup.java:6268)
System.err: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
System.err: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
System.err: at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
System.err: at android.view.View.layout(View.java:20871)
System.err: at android.view.ViewGroup.layout(ViewGroup.java:6268)
System.err: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
System.err: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
System.err: at android.view.View.layout(View.java:20871)
System.err: at android.view.ViewGroup.layout(ViewGroup.java:6268)
System.err: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
System.err: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
System.err: at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
System.err: at android.view.View.layout(View.java:20871)
System.err: at android.view.ViewGroup.layout(ViewGroup.java:6268)
System.err: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
System.err: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
System.err: at com.android.internal.policy.DecorView.onLayout(DecorView.java:758)
System.err: at android.view.View.layout(View.java:20871)
System.err: at android.view.ViewGroup.layout(ViewGroup.java:6268)
System.err: at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2942)
System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2457)
System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1553)
System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7569)
System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:958)
System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:770)
System.err: at android.view.Choreographer.doFrame(Choreographer.java:702)
System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:944)
System.err: at android.os.Handler.handleCallback(Handler.java:873)
System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
System.err: at android.os.Looper.loop(Looper.java:201)
System.err: at android.app.ActivityThread.main(ActivityThread.java:6831)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:927)
在使用webpack之前,我能够了解错误所在的代码行。但在这里我什至不了解错误。如何解决这个问题。以及如何识别vendor.js中的错误,该错误始终会给出一些android代码异常,这超出了跨平台技术的范围,因为我来这里是为了与js一起使用而不是与某些android代码一起工作。我只希望我写的js错误。
答案 0 :(得分:0)
好的,我犯了一个错误,那就是在创建项目后我运行命令
npm install -g nativescript
因此本机脚本版本为6.3.0
,而我没有更新platforms
和tns-core-modules
因此,我删除了该项目并创建了一个新项目。然后它创建了platforms
和tns-core-modules
的匹配版本并解决了问题
否则我们可以通过
删除platforms
和tns-core-modules
并创建一个新的
tns platform remove android
tns platform add android
npm install tns-core-modules@latest --save