android - Nativescript RadDataForm : JS: Binding: 设置 RadDataForm 的属性源时出现绑定错误
问题描述
我正在尝试使用 nativescript RadformData,但是当我绑定数据模型时,当我导航到 Radformdata 页面时,我总是收到此错误“JS:绑定:设置 RadDataForm 的属性源时出现绑定错误” ,我尝试了很多方法更改 package.json 中的数据表单版本我也清理了平台但没有运气,请咨询
这是我的代码: event-page.xml
<Page loaded="onPageLoaded" xmlns:df="nativescript-ui-dataform"
xmlns="http://www.nativescript.org/tns.xsd">
<ActionBar title="Add Event" />
<df:RadDataForm id="myDataForm" source="{{ calEvent }}">
<df:RadDataForm.properties>
<df:EntityProperty name="title" hintText="Title" index="0">
<df:EntityProperty.editor>
<df:PropertyEditor type="Text"></df:PropertyEditor>
</df:EntityProperty.editor>
</df:EntityProperty>
<df:EntityProperty name="description" hintText="Description" index="1">
<df:EntityProperty.editor>
<df:PropertyEditor type="Text"></df:PropertyEditor>
</df:EntityProperty.editor>
</df:EntityProperty>
<df:EntityProperty name="stringDate" hintText="select date" index="2">
<df:EntityProperty.editor>
<df:PropertyEditor type="DatePicker"></df:PropertyEditor>
</df:EntityProperty.editor>
</df:EntityProperty>
<df:EntityProperty name="dateDate" hintText="select date" index="3">
<df:EntityProperty.editor>
<df:PropertyEditor type="DatePicker"></df:PropertyEditor>
</df:EntityProperty.editor>
</df:EntityProperty>
<df:EntityProperty name="timestampDate" hintText="select date" index="4" converter="{{ timestampConverter }}">
<df:EntityProperty.editor>
<df:PropertyEditor type="DatePicker"></df:PropertyEditor>
</df:EntityProperty.editor>
</df:EntityProperty>
<df:EntityProperty name="stringTime" hintText="select time" index="5">
<df:EntityProperty.editor>
<df:PropertyEditor type="TimePicker"></df:PropertyEditor>
</df:EntityProperty.editor>
</df:EntityProperty>
<df:EntityProperty name="dateTime" hintText="select time" index="6">
<df:EntityProperty.editor>
<df:PropertyEditor type="TimePicker"></df:PropertyEditor>
</df:EntityProperty.editor>
</df:EntityProperty>
<df:EntityProperty name="timestampTime" hintText="select time" index="7" converter="{{ timestampConverter }}">
<df:EntityProperty.editor>
<df:PropertyEditor type="TimePicker"></df:PropertyEditor>
</df:EntityProperty.editor>
</df:EntityProperty>
</df:RadDataForm.properties>
</df:RadDataForm>
</Page>
事件页面.ts
import { EventViewModel } from "./event-view-model";
import { Page } from "tns-core-modules/ui/page/page";
export function onPageLoaded(args) {
const page = <Page>args.object;
var eventModel = new EventViewModel();
page.bindingContext = eventModel;
}
事件视图模型.ts
import { Observable } from "tns-core-modules/data/observable";
import { PropertyConverter } from "nativescript-ui-dataform";
export class EventViewModel extends Observable {
private _event: CalEvent;
constructor() {
super();
this.set("timestampConverter", new TimestampConverter());
this.onSetDefaults();
}
public onSetDefaults() {
const stringDate = "1999-08-11";
const dateDate = new Date();
const timestampDate = (new Date()).getTime();
const stringTime = "11:04";
const dateTime = new Date(1);
const timestampTime = (new Date()).getTime();
this._event = new CalEvent("First Event","Desc",stringDate, dateDate, timestampDate, stringTime, dateTime, timestampTime);
}
get calEvent(): CalEvent{
return this._event;
}
}
export class TimestampConverter implements PropertyConverter {
public convertFrom(timestamp: number) {
const date = timestamp ? new Date(timestamp) : null;
const result = date === null ? null : date.toJSON();
return result;
}
public convertTo(dateString: string) {
const date = new Date(dateString);
const result = date ? date.getTime() : 0;
return result;
}
}
export class CalEvent {
public title: string;
public description: string;
public stringDate: string;
public dateDate: Date;
public timestampDate: number;
public stringTime: string;
public dateTime: Date;
public timestampTime: number;
constructor(title: string, desc: string, stringDate: string, dateDate: Date, timestampDate: number, stringTime: string, dateTime: Date, timestampTime: number) {
this.title = title;
this.description = desc;
this.stringDate = stringDate;
this.dateDate = dateDate;
this.timestampDate = timestampDate;
this.stringTime = stringTime;
this.dateTime = dateTime;
this.timestampTime = timestampTime;
}
}
解决方案
推荐阅读
- office-js - 使用 Excel.js API 使用字节创建 excel 工作簿
- sql - 在 Excel VBA 中运行 SQL "SELECT ... INTO ... IN ...." 语句
- silverstripe - 将 SilverStripe 网站从一台服务器迁移到另一台服务器
- python - 尝试导入版本的python中的相对导入错误
- c# - 选择元素不可见 - Mac - Safari 11.1 - Selenium - C#
- html - 如何使引导 4 d-flex 单元的高度相等?
语境
我正在使用
<table>
带有 bootstrap 4 的元素d-flex
来呈现表格。单元格 (<td>
) 在一行 ( ) 中有不同的内容<tr>
,不幸的是这会导致不同的单元格高度问题
- sql-server - VS2017 SQL Server 数据库项目跨数据库查询
- kubernetes - 限制 Kubernetes 服务帐户访问特定命名空间
- android - 从 adobe 18.3 版本应用程序共享 pdf 时,我无法在共享菜单列表中看到我的 Android 应用程序
- c# - 如何使用 angularjs 发布 blob 并在 C# 中接收 blob 到电子邮件