如何将对象输出为具有格式的可读字符串(结构如下<pre>
)?
没有jQuery可能.
我的对象看起来像这样使用console.log
.
Object
title: "Another sting"
type: "tree"
options: Object
paging: "20"
structuretype: "1"
columns: Object
...
description: "This is a string"
...
Run Code Online (Sandbox Code Playgroud)
将它转换为结构化字符串的最佳方法是什么?
我的尝试:
我尝试使用stringify()
获取JSON结构.然后我可以编写自己的解析器,但也许已经有任何实现?
如何在单击span元素时显示跨度标题?通常,跨度标题显示在鼠标悬停上.所以当点击跨度时我想要相同的.如何才能做到这一点?
<span title="abc">def</span>
Run Code Online (Sandbox Code Playgroud) 使用Windows 7,Webstorm 10.0.1,当前node.js,npm,bower等.
我创建了默认的Webstorm AngularJS项目,没有更改任何内容并单击"运行index.html".页面已加载,但Angular未运行.从源头我看到文件丢失了<script src="bower_components/angular/angular.js"></script>
.目录bower_components
丢失了.然后我搜索它,它是在C:\Users\<username>\bower_components
我的Webstorm项目所在的时候创建的C:\Users\<username>\WebstormProjects\angularjs
.
需要更改哪些配置才能使我的AngularJS应用程序正常工作?
附加信息:
.bowerrc
{
"directory": "app/bower_components"
}
Run Code Online (Sandbox Code Playgroud)
bower.json
{
"name": "angular-seed",
"description": "A starter project for AngularJS",
"version": "0.0.0",
"homepage": "https://github.com/angular/angular-seed",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.2.x",
"angular-route": "1.2.x",
"angular-loader": "1.2.x",
"angular-mocks": "~1.2.x",
"html5-boilerplate": "~4.3.0"
}
}
Run Code Online (Sandbox Code Playgroud) 没有jQuery可能.
如何使用JavaScript禁用/停止鼠标移动?
怎么做:如果移动鼠标,让我们说position left < 300
,禁用ouse移动,以防止进一步向这个方向移动.
那可能吗?
我创建了一个窗口,其中包含发送ajax请求的网格.现在,在完全创建网格并返回ajax请求之前,我立即关闭窗口.
我有两个问题:
Chrome控制台会列出它们.虽然我的窗口有autoDestroy: true
窗格关闭后仍然存在网格面板和存储.关闭时,destroy
会触发该事件.文档说,窗口下的所有组件都应该被销毁.
问题是,回调尝试重新配置没有附加商店的网格.
错误:Uncaught TypeError: Cannot call method 'getCount' of null Table.js:500
(/lib/extjs/src/view/Table.js
如果我的窗口被销毁,如何停止处理回调?
控制器A通过承诺发送请求.在另一个控制器B中同时运行回调函数的最佳方法是什么?通过原始回调中的服务进行广播,并在另一个控制器中进行侦听.是否有可能将承诺传递给控制器B?
// controller A
service.doAjax().then( function( data ) {
// controller A callback
// should I broadcast "data" and listen for the event in controller B ?
} );
// controller B
$rootScope.$on();
// ... listen for the event sent from controller A to get "data
Run Code Online (Sandbox Code Playgroud)
// controller A
var promise = service.doAjax();
shareService.sharePromise( promise ); // Sharing the promise with broadcast
// controller B
// get promise from shareService via $on()
promise.then( function( data) {} );
Run Code Online (Sandbox Code Playgroud)
选项2的问题是回调函数将被执行多次.我不想共享数据,但执行回调.
我使用SplFileObject
和LimitIterator
来读取大文件中从位置 x 到 y 的内容。
当使用像/home/devel/stuff/myfile.log
.
当使用这样的路径时,http://mydomain.com:8090/devel/stuff/myfile.log
它不起作用。不过路径是正确的。
使用绝对路径时会失败吗?
错误消息是:
PHP Warning: SplFileObject::rewind() [<a href='splfileobject.rewind'>splfileobject.rewind</a>]: stream does not support seeking in ...
PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Cannot rewind file ...'
完整代码:
// $pStrFile contains the valid (yes!) path
$oFile = new SplFileObject($pStrFile);
// $nFrom = 80 and $nLines = 30
$fileIterator = new LimitIterator($oFile, $nFrom, $nLines);
foreach($fileIterator as $line) {
$strLines .= $line;
}
Run Code Online (Sandbox Code Playgroud) this
在调用我的回调函数时如何保持?
init: function() {
console.log( this ); // constructor, YES!
this.readConfig();
},
readConfig: function() {
console.log( this ); // constructor, YES!
this.httpApi.request({
module : 'monitor',
func : 'getConfig',
success : this.readConfigCallback,
scope : this
});
},
readConfigCallback: function(oResponse) {
console.log( this ); // Window, NO!
var oView = this.getView(); // error...
Run Code Online (Sandbox Code Playgroud)
}
我在ExtJs 4.1中得到了一个textarea,想要修改字体系列和大小.
style : 'font-family: courier new, font-size: 8px'
style : {
'fontFamily' : 'courier new',
'fontSize' : '8px'
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过这样:
oTextarea.el.applyStyles({
'font-family' : 'verdana',
'font-size' : '8px'
});
Run Code Online (Sandbox Code Playgroud) 我正试图在我的面板上显示一个加载蒙版.
使用view.setLoading()
或view.mask()
导致问题:
setLoading()
未锁定到面板/视图.如果拖动窗口/面板,带有消息的加载掩码将保留在拖动开始处,并且不会随其窗口/面板移动.加载消息完美无缺setLoading( 'Waiting...' );
mask()
锁定到面板/视图(是啊!),但是我无法向其添加加载消息.试过:.mask( 'Waiting...' )
和.mask( { msg: 'Waiting...' } )
.
我会使用任何方法,如果它可以锁定到视图并显示消息.怎么做?
看到这个:
var x = function() {
if(true) {
return false;
}
return true;
}
if( x === false) {
alert("OK");
} else {
alert("Wrong");
}
Run Code Online (Sandbox Code Playgroud)
检查小提琴.
为什么"错"?为什么这个功能没有false
按预期返回?