我正在尝试创建一个小的Javascript"框架",我可以在我的greasemonkey脚本中使用它.我只需要非常基本的功能,所以这就是我选择不使用mooTools或DOMAssistant的原因.此外,我不会傻到把DOMAssitant放在一个20KB的Greasemonkey脚本中!我只想要一小块整洁的代码片段.
我对下面的代码有一个小问题.我认为它是因为我在$()中返回一个数组所以我得到.setStyle不是一个函数错误消息.
var fmini = {
$ : function(a) {
var i=0,obj,d;
var e = [];
while (obj = arguments[i++]) {
d = document.getElementById(obj);
d.setStyle = fmini.setStyle;
d.each = fmini.each;
e.push(d);
}
return e;
},
setStyle : function(style, value) {
if (typeof this.style.cssText !== 'undefined') {
var styleToSet = this.style.cssText;
if (typeof style === 'object') {
for (var i in style)
if (typeof i === 'string') styleToSet += ';' + i + ':' + style[i];
}
else styleToSet …Run Code Online (Sandbox Code Playgroud) 我是extjs的新手.我想用extjs构建一个页面.
_________________________
| hd ______________________ |
| p1 <| p2 |
| | | - >将是一个视口(将在没有任何
| | |滚动条
| |
| | |
| | |
| ____________ | _______________ |的情况下调整窗口大小.
高清 - >标题宽度为100
p1 - >面板1将在西方折叠并且split = true
我构建了结构,但即使在窗口调整大小时也无法100%维护它
代码链
EditorUi = Ext.extend(Ext.Viewport, {
layout: 'fit',
initComponent: function() {
this.items = [{
xtype: 'panel',
title: 'Heading',
autoHeight: true,
autoWidth: true,
layout: 'hbox',
items: [{
xtype: 'panel',
title: 'Navigation',
collapsible: true,
region: 'west',
width: 200,
split: …Run Code Online (Sandbox Code Playgroud) 有没有办法使用原型与Jquery共存.
我的意思是不是Jquery与Jquery NoConflict标签的原型,但反过来.
我必须覆盖原型实用程序方法与其他库共存?
我无法控制Jquery Scripts
Backbone.js,Express,Ext JS和JSPP的优点和缺点是什么?
我在testFun.js中有一个函数
var testFunc=function{
var hasCar=false;
return{
checkCar: function(){
for(var i=0; i<5; i++){
MyCar.check(hasCar); //defined in following MyCar.js
}
}
}
}();
Run Code Online (Sandbox Code Playgroud)
MyCar.js中的另一个功能
var MyCar=function(){
var createCar=function(){
//Create a car
//var car = new Car();
}
return{
check: function(hasCar){
console.log(hasCar); //PROBLEM HERE: fierBug console output is "false" always even CHECK_BUTTON has been clicked, why?
var handler=function(){
if(!hasCar)
createCar();
hasCar=true;
}
//CHECK_BUTTON is a button on UI
CHECK_BUTTON.click(handler);
}
}
}();
Run Code Online (Sandbox Code Playgroud)
正如您在MyCar模块模式中看到的,CHECK_BUTTON单击何时,我将调用createCar()function,并将hasCar …
我在网格中有以下代码:
var grid = Ext.create('Ext.grid.Panel', {
store: store,
stateful: true,
stateId: 'stateGrid',
columns: [
{
text : 'Job ID',
width : 75,
sortable : true,
dataIndex: 'id'
},
{
text : 'File Name',
width : 75,
sortable : true,
dataIndex: 'filename',
listeners : {
'mouseover' : function(iView, iCellEl,
iColIdx, iRecord, iRowEl, iRowIdx, iEvent) {
var zRec = iView.getRecord(iRowEl);
alert(zRec.data.id);
}
}
Run Code Online (Sandbox Code Playgroud)
...等等...
我无法弄清楚如何获取行中第一列的单元格值.我也尝试过:
var record = grid.getStore().getAt(iRowIdx); // Get the Record
alert(iView.getRecord().get('id'));
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
提前致谢!
我是Javascript MVC框架Knockout.js的初学者
来自传统的Javascript(和一些jQuery经验),我在理解语法学习Knockout.js时遇到了困难
考虑下面的陈述;
风景:
<ul class="folders" data-bind="foreach: folders">
<li data-bind="text: $data,
css: { selected: $data == $root.chosenFolderId() },
click: $root.goToFolder"></li></ul>
Run Code Online (Sandbox Code Playgroud)
查看型号:
function WebmailViewModel() {
// Data
var self = this;
self.folders = ['Inbox', 'Archive', 'Sent', 'Spam'];
self.chosenFolderId = ko.observable();
// Behaviours
self.goToFolder = function(folder) { self.chosenFolderId(folder); };
};
Run Code Online (Sandbox Code Playgroud)
你能解释一下这些陈述是什么(特别是$ data,$ root)吗?该声明的作用self.chosenFolderId(folder);是什么?
我有许多功能方法我需要使用它,我需要发布一个使用这种方法的库与JavaScript开发人员分享它非常有用,所以例如我需要添加一个名为的方法duplicates 将返回给我的数组的重复项你可以看到ECMA没有正式发布这个方法所以我不知道放置脚本的最佳形式
1-
Array.prototype.duplicate = function (){
//script here its usefull to use `this` refer to the Array
}
Run Code Online (Sandbox Code Playgroud)
使用它就像
[1,2,2].duplicates();
Run Code Online (Sandbox Code Playgroud)
2-
var Ary = function(a){
if(!(this instanceOf Ary))
return new Ary(a)
if(Object.prototype.toString.call(a) != '[object Array]')
return new Error(a + 'is not an Array')
else
{
for(var i =0 ; i<a.length; i++)
{
this.push(a[i]);
}
}
}
Ary.prototype = new Array();
Ary.prototype.constructor = Ary;
Ary.prototype.duplicates = function(){
//script here its usefull to use `this` refer to the Array
}; …Run Code Online (Sandbox Code Playgroud) 我在Angular 2中还很陌生。我正在研究如何在Angular应用程序中创建模块,并且我对以下与我正在关注的教程有关的疑问有所疑问。
我的怀疑与路由有关。
因此,在我的示例中定义了AuthModule模块:
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { SigninComponent } from './signin/signin.component';
import { SignupComponent } from './signup/signup.component';
import { AuthRoutingModule } from './auth-routing.module';
@NgModule({
// Components and directives used by the module:
declarations: [
SigninComponent,
SignupComponent
],
// Import modules used by this features module:
imports: [
FormsModule,
AuthRoutingModule
]
})
export class AuthModule {}
Run Code Online (Sandbox Code Playgroud)
并且我定义了相关的rotues配置类:
import { NgModule } from '@angular/core';
import …Run Code Online (Sandbox Code Playgroud) 所以我正在使用vue创建一个应用程序,在页面加载时它需要一个带有用户zip的cookie并使用该zip执行搜索,但是如果用户的错误,也允许用户更改该zip,所以我希望能够调用从更改zip时运行的常规方法内部创建的方法是否可以在Vue中实现?
javascript ×8
jquery ×3
extjs ×2
angular ×1
conflict ×1
extjs4 ×1
frameworks ×1
knockout.js ×1
node.js ×1
prototypejs ×1
typescript ×1
vue.js ×1