TypeError: Cannot read property 'slice' of null
TypeError: Cannot read property 'slice' of null
我在我的项目中使用自动表单,当我打开表单时出现这个错误
不确定这是否是因为任何版本或依赖性,我的自动表单无法正常工作并且我收到此错误,我有屏幕截图和模式代码,下面的表单代码,
模板
<template name="assesmentNew">
{{#ionModal customTemplate=true}}
{{# autoForm collection="Assesments" id="assesments-new-form" type="insert"}}
<div class="bar bar-header bar-stable">
<button data-dismiss="modal" type="button" class="button button-clear">Cancel</button>
<h2 class="title">New Assesment</h2>
<button type="submit" class="button button-positive button-clear">Save</button>
</div>
<div class="content has-header overflow-scroll">
{{> afQuickField name="name" }}
{{> afQuickField name="email"}}
{{> afQuickField name="category"}}
{{> afQuickField name="location"}}
</div>
{{/autoForm}}
{{/ionModal}}
</template>
Collection
Assesments = new Mongo.Collection('assesments');
Assesments.before.insert(function (userId, doc) {
doc.createdAt = new Date();
});
Assesments.attachSchema(new SimpleSchema({
name: {
type: String,
label: 'First Name',
autoform: {
'label-type': 'floating',
placeholder: 'First Name'
}
},
email: {
type: String,
label: 'Email',
autoform: {
'label-type': 'floating',
placeholder: 'Email'
}
},
category: {
type: String,
label: 'Category',
optional: true,
autoform: {
options: [
{value: 'General', label: 'General'},
{value: 'Reported', label: 'Reported'},
{value: 'Follow Up', label: 'Follow Up'}
],
type: 'select-radio'
}
},
assesmentDate: {
type: Date,
label: 'Assesment Date',
optional: true
},
location: {
type: String,
label: 'Location',
autoform: {
'label-type': 'floating',
placeholder: 'Location'
},
max: 200
},
createdBy: {
type: String,
autoValue: function() {
return this.userId
}
}
}
));
if (Meteor.isServer) {
Assesments.allow({
insert: function (userId, doc) {
return true;
},
update: function (userId, doc, fieldNames, modifier) {
return true;
},
remove: function (userId, doc) {
return true;
}
});
}
这是新版 autoform 的 autoform-ionic 新补丁的问题。
显然有些标签被跳过,有些则没有(参见 here)。为了解决这个问题并在您的输入类型不存在时避免此错误(例如,type = number
),自动表单呈现的所有模式字段都必须定义一个标签类型选项:
...
autoform: {
'label-type': 'placeholder',
placeholder: 'Linha'
}
我在我的项目中使用自动表单,当我打开表单时出现这个错误 不确定这是否是因为任何版本或依赖性,我的自动表单无法正常工作并且我收到此错误,我有屏幕截图和模式代码,下面的表单代码,
模板
<template name="assesmentNew">
{{#ionModal customTemplate=true}}
{{# autoForm collection="Assesments" id="assesments-new-form" type="insert"}}
<div class="bar bar-header bar-stable">
<button data-dismiss="modal" type="button" class="button button-clear">Cancel</button>
<h2 class="title">New Assesment</h2>
<button type="submit" class="button button-positive button-clear">Save</button>
</div>
<div class="content has-header overflow-scroll">
{{> afQuickField name="name" }}
{{> afQuickField name="email"}}
{{> afQuickField name="category"}}
{{> afQuickField name="location"}}
</div>
{{/autoForm}}
{{/ionModal}}
</template>
Collection
Assesments = new Mongo.Collection('assesments');
Assesments.before.insert(function (userId, doc) {
doc.createdAt = new Date();
});
Assesments.attachSchema(new SimpleSchema({
name: {
type: String,
label: 'First Name',
autoform: {
'label-type': 'floating',
placeholder: 'First Name'
}
},
email: {
type: String,
label: 'Email',
autoform: {
'label-type': 'floating',
placeholder: 'Email'
}
},
category: {
type: String,
label: 'Category',
optional: true,
autoform: {
options: [
{value: 'General', label: 'General'},
{value: 'Reported', label: 'Reported'},
{value: 'Follow Up', label: 'Follow Up'}
],
type: 'select-radio'
}
},
assesmentDate: {
type: Date,
label: 'Assesment Date',
optional: true
},
location: {
type: String,
label: 'Location',
autoform: {
'label-type': 'floating',
placeholder: 'Location'
},
max: 200
},
createdBy: {
type: String,
autoValue: function() {
return this.userId
}
}
}
));
if (Meteor.isServer) {
Assesments.allow({
insert: function (userId, doc) {
return true;
},
update: function (userId, doc, fieldNames, modifier) {
return true;
},
remove: function (userId, doc) {
return true;
}
});
}
这是新版 autoform 的 autoform-ionic 新补丁的问题。
显然有些标签被跳过,有些则没有(参见 here)。为了解决这个问题并在您的输入类型不存在时避免此错误(例如,type = number
),自动表单呈现的所有模式字段都必须定义一个标签类型选项:
...
autoform: {
'label-type': 'placeholder',
placeholder: 'Linha'
}