是否有可能在grunt中观看文件并自动重新加载ASP.net MVC Web应用程序.或者livereload仅适用于通过grunt提供的文件.我遇到过grunt插件'grunt-iisexpress',但不确定我是否可以使用它,结合任务在文件发生变化时重新加载ASP.net MVC webapp.
我没有任何index.html作为我的网络应用程序中的起始页面,但_ViewStart.cshtml启动了整个应用程序.
myFunction.call(thisArg, arg1, arg2 ...)
Run Code Online (Sandbox Code Playgroud)
我的理解是,当我使用call方法,并提供thisArg了this在功能值反对我通过英寸
myFunction.bind(thisArg, arg1, arg2 ...)
Run Code Online (Sandbox Code Playgroud)
bind另一方面,该方法返回一个新函数,其中新函数的上下文this设置为我传入的对象.
但我不明白的是为什么用bind而不是call.如果我想做的就是改变背景this,call对我来说似乎已经足够了.那么为什么在浏览器IE8及以下版本中断时会使用bind.
那么,什么时候使用bind成为一个更好的案例相比call?
我有以下设置为requireJS.
requirejs.config({
paths: {
'resources' : '/Scripts/resources'
},
shim: {
'resources': {
exports: 'LocalizedStrings'
}
}
});
Run Code Online (Sandbox Code Playgroud)
我的资源.JS如下所示:
LocalizedStrings = {
title: "Demo",
save: "Save"
}
Run Code Online (Sandbox Code Playgroud)
现在当我在main.JS文件中加载资源作为依赖项时,我可以访问LocalizedStrings并且它可以工作.
//main.js
define(function(require){
var LocalizedStrings = require('resources');
console.log(LocalizedStrings); //works as expected
});
Run Code Online (Sandbox Code Playgroud)
但是在其他模块上,我并不需要将资源作为依赖项加载到"LocalizedStrings".
//othermodule.js
define(function(require){
console.log(LocalizedStrings); //works as expected even though resources dependency is not loaded
});
Run Code Online (Sandbox Code Playgroud)
我在这里不明白的是,如果我使用shim加载一个JS文件并加载一次,它是否全局可用,我不必再在其他模块中加载相同的依赖项.