这不是来自属性的功能。
在Polymer Element中,我有类似的东西:
this.$.register.addEventListener('iron-form-presubmit',
function() {
//Hides the element...
this.$$('#js-error-username-invalid, #js-error-message').setAttribute('style', 'display:none');
//Removes the invalid attribute
setInvalid(this.root, false);
});
//What to do when a form returns an error, such as the username does not exist.
this.$.register.addEventListener('iron-form-error', function (event) {
//Sends invalid to everyone.
setInvalid(this.root, true);
console.log(event);
this.$$("#js-error-message").removeAttribute('style');
this.$$("#js-error-message").innerHTML = event.detail.request.xhr.response.error_description
});
现在我想在一个单独的文件上定义一个具有如下函数的行为:
_setError : function(query) {
var elems = Array.prototype.slice.call(Polymer.dom(this.root).querySelectorAll(query));
elems.forEach(function(element) {
element.setAttribute('invalid', '');
});
}
所有那些querySelectors,我想将它们作为参数传递,所以我几乎可以在有表单的地方重用这个逻辑。我试过挖掘一些文件,但我没有找到任何帮助我的东西。
答案 0 :(得分:1)
答案很简单:
如果你有这样的行为:
> sqllocaldb info
MSSQLLocalDB
> dotnet ef migrations add Initial
Project MvcMovie (.NETCoreApp,Version=v1.0) will be compiled...
Compiling MvcMovie for .NETCoreApp,Version=v1.0
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:01.7783361
Done. To undo this action, use 'dotnet ef migrations remove'
> dotnet ef database update
Project MvcMovie (.NETCoreApp,Version=v1.0) was previously...
Done.
就这样称呼它:
MyBehavior.FormSubmit = {
_hello : function(ma) {
alert(ma);
},