我是 VueJS 的新手,所以我一直遵循他们的官方指南。
我能够触发前 5 个属性验证器,但我似乎无法触发最后一个示例(自定义验证函数)。
我的JS文件:
Vue.component('propValidation', {
props: {
// basic type check (`null` means accept any type)
propA: Number,
// multiple possible types
propB: String,
// a required string
propC: {
type: String,
required: true
},
// a number with default value
propD: {
type: Number,
default: 100
},
// object/array defaults should be returned from a
// factory function
propE: {
type: Object,
default: function () {
return { message: 'hello' }
}
}, …Run Code Online (Sandbox Code Playgroud) 跨浏览器处理有时很麻烦.
在这种情况下,我需要捕获相当多的事件,但不能使用超过10ish Kb的多用途库.(例如jQuery,Prototype,Dojo,YUI,......)
该脚本是我正在维护的各种站点的基本跟踪工具.
alt text http://img411.imageshack.us/img411/4185/7yfa521.png
如果有人能指出我用于跨浏览器事件处理的javascript库,我会很高兴.
这将是我的一天!=)
我已经看到这个标签在javascript函数之后使用了十多年了,从未问过为什么.在我这次看过的大部分教程中都可以看到它,但我通常会把它排除在外......它似乎没有这种或那样的效果.任何人都可以告诉我为什么使用这个?
如果它只是表示javascript函数的结束,那么右支撑是否足够?如果是一系列函数,则使用结束脚本标记.
我怀疑我需要一个例子,但是对于那些也想知道它是什么的所有其他读者,这里是一些代码:
function helloWorld() {
document.write('Hello World');
}
//-->
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我在这里看到了一个javascript MVC文章,模型定义为:
var ListModel = function (items) {
this._items = items;
this._selectedIndex = -1;
this.itemAdded = new Event(this);
this.itemRemoved = new Event(this);
this.selectedIndexChanged = new Event(this);
};
ListModel.prototype = {
getItems : function () {
return [].concat(this._items);
},
addItem : function (item) {
this._items.push(item);
this.itemAdded.notify({item: item});
},
removeItemAt : function (index) {
var item = this._items[index];
this._items.splice(index, 1);
this.itemRemoved.notify({item: item});
if (index == this._selectedIndex)
this.setSelectedIndex(-1);
},
getSelectedIndex : function () {
return this._selectedIndex;
},
setSelectedIndex : function (index) …Run Code Online (Sandbox Code Playgroud) javascript model-view-controller javascript-events javascript-framework
有关List的文档提到itemTpl遵循XTemplate语法.
我想在itemTpl中使用成员函数
如果我使用XTemplate初始化itemTpl并且成员函数没有参数它可以工作:
items: {
xtype: 'list',
store: myStore,
itemTpl: new Ext.XTemplate('<i>{name} {[this.hello()]}</i>', {
hello: function () {
return 'Hello';
}
})
Run Code Online (Sandbox Code Playgroud)
但是一旦我尝试传递一个参数(如下面的两个例子中),它就不再起作用了:
items: {
xtype: 'list',
store: myStore,
itemTpl: new Ext.XTemplate('<i>{name} {[this.helloWorld(name)}</i>', {
helloWorld: function (name) {
return 'Hello ' + name;
}
})
items: {
xtype: 'list',
store: myStore,
itemTpl: new Ext.XTemplate('<i>{name} {name:helloWorld}</i>', {
helloWorld: function (string) {
return 'Hello ' + name;
}
})
Run Code Online (Sandbox Code Playgroud)
TypeError:'undefined'不是函数(评估'fm.helloWorld(values ['name'])')
我想我不应该创建一个新的Ext.XTemplate对象.是否有任何解决方案来传递成员函数而不创建单独的XTemplate?
或者我应该放弃列表并在模板中自己构建列表?
我正在构建一个Backbone应用程序,我遇到了这个奇怪的问题.在州A(路线:""),我有一个这样的观点:
var view = Backbone.View.extend({
events : {
"click a.continue" : "next"
},
next : function(e) {
//Some stuff
Backbone.history.navigate("/page2");
}
});
Run Code Online (Sandbox Code Playgroud)
一旦我用" 继续 "类点击锚点,我就被重定向到状态B(路由:"/ page2").如果我单击浏览器的后退按钮,然后单击锚点,调试我注意到下一个函数被触发两次.实际上,如果我继续来回,事件被触发的次数会不断增加.
任何线索?
提前致谢
我在我的应用程序中使用extjs字段容器,我在表单中有详细信息,资金,家属部分.在基金和家属部分,我有一个"添加另一个"按钮,用于在每次点击按钮时添加新的订单项.
这是我创建的表单 http://jsbin.com/evevod/4/edit
我是extjs4的新手.任何人都可以帮我如何动态创建项目onclick.
我正在尝试学习backbone.js,但我仍然坚持抓取json并添加到集合中.集合未定义,我不知道为什么.码:
$(document).ready(function() {
(function($) {
//model
window.Wine = Backbone.Model.extend();
window.WineCollection = Backbone.Model.extend({
url: "http://localhost/bootstrap/json.php",
model: Wine
});
//views
window.WineItemView = Backbone.View.extend({
template: _.template($("#wine-item-template").html()),
tagName: 'li',
render: function() {
$(this.el).html(this.template(this.model.toJSON()));
return this;
}
});
window.WineListView = Backbone.View.extend({
tagName: 'ul',
initialize: function() {
this.model.bind('reset', this.render, this);
},
render: function() {
_.each(this.model.models, function(wine) {
$(this.el).append(new WineItemView({
model: wine
}).render().el);
}, this);
return this;
}
});
window.WineView = Backbone.View.extend({
template: _.template($('#wine-template').html()),
render: function() {
$(this.el).html(this.template(this.model.toJSON()));
return this;
}
});
//Router
window.AppRouter = Backbone.Router.extend({
routes: …Run Code Online (Sandbox Code Playgroud) 我的Backbone应用程序包含依赖于多个模型的视图.例如,我定义了2个模型:
var user = new UserModel({id:1});
user.fetch();
var place = new PlaceModel({id:1});
place.fetch();
Run Code Online (Sandbox Code Playgroud)
现在我想呈现一个依赖于这两个模型的View:
var home = new House({owner: user, address: place});
home.render()
Run Code Online (Sandbox Code Playgroud)
在确定所有模型都已加载之前,我不想渲染视图.
什么是确保在渲染之前获取user并place同时获取的正确方法home?
我目前正在使用顺序流程:
user.bind("change", function() {place.fetch();});
place.bind("change", function() {home.render();});
user.fetch();
Run Code Online (Sandbox Code Playgroud)
但随着依赖关系的增长,这变得笨拙,我觉得必须有更好的方法......
我看到很多很好的客户端框架正在出现以构建Web GUI(最近的http://yeoman.io/).当服务器端都是Java EE时,我们应该如何利用这些框架?他们都没有提供任何详细信息.如果您分享如何利用这些框架,我将不胜感激.
javascript ×9
backbone.js ×3
dom-events ×3
extjs ×2
extjs4 ×1
html ×1
java ×1
java-ee ×1
requirejs ×1
sencha-touch ×1
vue.js ×1