首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >RadListView Telerik UI“无法读取未定义的属性'setLayoutParams‘”

RadListView Telerik UI“无法读取未定义的属性'setLayoutParams‘”
EN

Stack Overflow用户
提问于 2017-09-19 09:13:11
回答 1查看 715关注 0票数 1

在尝试使用来自TelerikUI的TelerikUI时,我遇到了一个无法掌握的错误。根据角度样本,我

导入我的submodule.ts文件中的模块

代码语言:javascript
运行
复制
import { NativeScriptUIListViewModule } from "nativescript-telerik-ui/listview/angular";

代码语言:javascript
运行
复制
@NgModule({


 imports: [
    NativeScriptModule,
    NativeScriptI18nModule,
    NativeScriptRouterModule,
    subRouting,
    NativeScriptUIListViewModule,
  ],
  declarations: [
    ListPageComponent,
  ],
  exports: [
  ]
})
export class SubModule {}

在ListPageComponent中创建数据对象定义

代码语言:javascript
运行
复制
class DataItem {
    constructor(public id: string, public type: string) { }
}

并编写了我的组件类

代码语言:javascript
运行
复制
@Component({
    selector: "list",
    moduleId: module.id,
    templateUrl: "list.page.html",
    styleUrls: ["list.page.css"]
})
export class ListPageComponent implements OnInit {

    public _dataItems: DataItem[] = [
        {id: "1", type: "A"},
        {id: "2", type: "A"},
        {id: "3", type: "A"}
    ];
    get dataItems(): ObservableArray<DataItem> {
        return new ObservableArray(this._dataItems);
    }


    constructor(
        private _pageRoute: PageRoute,
        private _routerExtensions: RouterExtensions,
        private _page: Page
    ){
    }

    ngOnInit(): void {
    }        
}

最后,尝试按照

代码语言:javascript
运行
复制
<GridLayout columns="*" rows="*">
    <RadListView [items]="dataItems" col="0" row="1">
        <ng-template tkListItemTemplate let-item="item">
            <GridLayout columns="auto" rows="auto">
                <Label class="descriptionLabel" [text]="item.type" col="0" row="0"></Label>
            </GridLayout>
        </ng-template>        
    </RadListView>
</GridLayout>

该示例适用于基本的列表视图,但切换到RadListView引发

代码语言:javascript
运行
复制
An uncaught Exception occured on "main" thread. com.tns.NativeScriptException:
Calling js method onCreateViewHolder failed

Type Error: Cannot read property 'setLayoutParams' of undefined File: "file:///data/data/org.nativescript.myapp/files/app/tns_modules/nativescript-telerik-ui/listview/listview.js, line: 102 column: 42

StackTrace:
Frame: function:'ListViewAdapter.onCreateViewHolder', file"file:///data/data/org.nativescript.myapp/files/app/tns_modules/nativescript-telerik-ui/listview/listview.js, line: 102 column: 43

at com.tns.Runtime.callJSMethodNative (Native Method) [...]

在我的android模拟器上(还没有机会在ios上进行测试)

似乎,我对RadListView做了一个基本的错误,虽然我保持了与本地文本-ui-样本的角度应用程序完全一致。

我的package.json节选

代码语言:javascript
运行
复制
"nativescript": {
        "id": "org.nativescript.myapp",
        "tns-android": {
            "version": "3.1.1"
        },
        "tns-ios": {
            "version": "3.1.0"
        }
    },
    "dependencies": {
        "@angular/animations": "~4.2.0",
        "@angular/common": "~4.2.0",
        "@angular/compiler": "~4.2.0",
        "@angular/core": "~4.2.0",
        "@angular/forms": "~4.2.0",
        "@angular/http": "~4.2.0",
        "@angular/platform-browser": "~4.2.0",
        "@angular/router": "~4.2.0",
        "moment": "^2.18.1",
        "nativescript-angular": "~4.2.0",
        "nativescript-gif": "^2.0.0",
        "nativescript-i18n": "^0.2.2",
        "nativescript-telerik-ui": "^3.1.0",
        "nativescript-theme-core": "~1.0.4",
        "reflect-metadata": "~0.1.8",
        "rxjs": "~5.4.2",
        "tns-core-modules": "~3.1.1",
        "zone.js": "~0.8.2"
    },

任何暗示都是非常感谢的。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-19 09:36:41

您需要将所有内容更新为最新版本的tns plugin update。还将android和ios版本更新为3.2.0

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46296398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档