再次,我有一个nanoc文件的问题.这次我想将自定义文件附加slide.js到我的博客但我不能(不知道为什么 - 可能是我的路线出了问题).这是我的路线:
compile '/js/*/' do
# don’t filter or layout
end
...
route '/js/*/' do
/'js'/ + item.identifier.chop + '.js'
end
Run Code Online (Sandbox Code Playgroud)
在head我的布局部分,我已经说过:( %script{:type => "text/javascript", :src => "/js/slide.js"}/是的,这是一个HAML).
任何人都可以帮我解决这个问题吗?非常感谢.
我的应用程序网址具有全局属性/变量:
Vue.prototype.$apiUrls = {
root: 'http://localhost:8080/',
api: 'api/v1/'
// etc.
}
Run Code Online (Sandbox Code Playgroud)
我根据axios请求在组件内部使用它:
axios.get(`${this.$apiUrls.root}${this.$apiUrls.api}/users/`)
Run Code Online (Sandbox Code Playgroud)
现在,我想测试组件的代码,已经进行了模拟axios,但仍然收到错误:
TypeError: Cannot read property '$apiUrls' of undefined
Run Code Online (Sandbox Code Playgroud)
我试图在每个测试中和/或在JEST的安装文件中定义/模拟此属性,例如
global.$apiUrls = {...}
// or
Vue.prototype.$apiUrls = {...}
// or
Object.defineProperties(Vue.prototype, {$apiUrls: {...}})
Run Code Online (Sandbox Code Playgroud)
我也曾尝试将其嘲笑为windowor this(是的,这很愚蠢),但没有成功-我仍然收到该错误-请帮助。
就像我在标题中提到的那样 - 每次我做出任何改变以查看它的样子时我都必须预编译资产 - 我已经尝试过config.assets.compile = true,但没有成功.
我也试过RAILS_ENV = 'development'但效果相同.请帮助我,因为它真的很烦人.
我的系统正在运行:
我也尝试过:
config.action_controller.perform_caching = true
Run Code Online (Sandbox Code Playgroud) 今天我在nanoc(haml模板)中实现我的页面,我想在markdown中写一些帖子,但是当它转到多行代码块时会出现一些奇怪的事情 - 代码块中的第二行有其他标签.我尝试了多种markdown语法,例如:
//double tab wrapping
line 1 is fine
line 2 is wrapping (don't know why!)
Run Code Online (Sandbox Code Playgroud)
和
~~~
//tilde code wrapping
line 1 is fine
line 2 is wrapping
~~~
Run Code Online (Sandbox Code Playgroud)
两种解决方案都给我这样的结果:
line 1 is fine
line 2 is wrapping
Run Code Online (Sandbox Code Playgroud)
通过浏览器检查元素显示没有额外的填充 - 这个空格是用标签确定的.
有人可以帮我弄这个吗?也许我做错了什么?
我正在将canvas转换为dataURL(base64)类型,我想使用PhoneGap的编写器将其保存到手机文件系统,但没有成功(我得到了无法打开的文件) - 这是我的一些代码:
var dataURL = document.getElementById("gen").toDataURL('image/png'); //substr() .replace('datadata:image/png;base64,', '');
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
function gotFS(fileSystem) {
fileSystem.root.getFile("screenshot.png", {create: true, exclusive: false}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
console.log("open and write");
writer.seek(0);
writer.write(dataURL);
console.log("close and save");
}
function fail(error) {
console.log(error.code);
}
var fileTransfer = new FileTransfer();
fileTransfer.download("/", screenshot.png,
function(entry) {
alert("download complete");
},
function(error) {
alert("download error source " + error.source);
alert("download error target " + error.target);
alert("upload error code" + error.code);
} …Run Code Online (Sandbox Code Playgroud) 我有一个myList包含5个元素的列表,但是我想通过使用命令将其切成模板:
{% for item in myList|slice:"3" %}
或此命令:
{% for item in myList|slice:":3" %}
slice:"x"和之间有什么区别slice:":x"?(我目前无法访问已安装django的计算机,但很好奇)
我有两个型号:sites和articles.每个站点可以有多个文章.我想在这条路线中查看这篇文章:/siteName/articleFriendlyTitleUrl.目前我有帮助方法来制作这样友好的网址:
getFriendlyUrl = function(urlString){
urlString = urlString.toLowerCase();
urlString = str.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '-');
return urlString;
}
Run Code Online (Sandbox Code Playgroud)
我的router.js档案:
this.route('showArticle', {
path: '/article/:title'),
layoutTemplate: 'artLayout',
data: function(){
viewData = {
title: Articles.findOne({title: this.params.title}),
site: Sites.findOne({name: this.name})
}
return viewData;
});
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何实现这个?我也试过这个路径:
/:siteName/:articleId
Run Code Online (Sandbox Code Playgroud)
但没有成功 - 任何建议?
这次我有一个C#编程问题:我有一个列表列表:
List<List<string>> List1
Run Code Online (Sandbox Code Playgroud)
其中的字符串列表:
List<string> List2
Run Code Online (Sandbox Code Playgroud)
并且,在循环中,我想将List2放在List1中,但是,我想要更改List2中的值,但我不想在List2中插入的List2中更改此值.这是我想要做的伪代码的例子(因为我想没有人得到我想要的东西):
List1 <=> ['one', 'two', 'three']
List2[1] <=> List1
List1.clear
List1 <=> ['four', 'five', 'six']
List2[2] <=> List1
Run Code Online (Sandbox Code Playgroud)
但List1也改变了List2 [1] - 我不想那样!现在看起来像:
List2[1] <=> ['four', 'five', 'six']
List2[2] <=> ['four', 'five', 'six']
Run Code Online (Sandbox Code Playgroud)
但我希望它会:
List2[1] <=> ['one', 'two', 'three']
List2[2] <=> ['four', 'five', 'six']
Run Code Online (Sandbox Code Playgroud)
重点是什么?我希望这些List1s保持在那个状态,当我将它们插入List2时会有什么.我希望有人能理解这一点并帮助我.我知道我在List2中插入了某种List1指针,但是如何使它正确?(右 - >我希望它工作的方式^^)
这是我的问题:
我正在使用 ddSlick 插件来实现带有标志的语言下拉菜单。问题是我正在从 xml 文件动态创建这个下拉列表。一切顺利,选择创建正确,但 ddSlick 插件没有看到这些选项字段。我 100% 确定它们具有所有必要的数据值。
此外,ddSlick 似乎在我的脚本之前运行(即使它在我的脚本之后链接),因为当我以静态方式放置我的选项时(不是通过解析 xml,而是直接将其放入 HTML 文档)一切正常。这是我的代码:
运行我的 xml2html js 函数之前的 HTML:
<form>
<select id='countries' name='countries'>
</select>
</form>
Run Code Online (Sandbox Code Playgroud)
xml解析后的HTML:
<form>
<select id='countries' name='countries'>
<option data-imagesrc="css/images/flags/Select...jpg" data-description="Select.." value="0">Select..</option>
<option data-imagesrc="css/images/flags/United States.jpg" data-description="United States" value="1">United States</option>
<option data-imagesrc="css/images/flags/United Kingdom.jpg" data-description="United Kingdom" value="2">United Kingdom</option>
<option data-imagesrc="css/images/flags/France.jpg" data-description="France" value="3">France</option>
</select>
</form>
Run Code Online (Sandbox Code Playgroud)
ddSlick 运行后的 HTML:
<form>
<div id="countries" class="dd-container" style="width: 260px;">
<div class="dd-select" style="width: 260px; background-color: rgb(238, 238, 238); background-position: initial initial; background-repeat: initial initial;">
<input class="dd-selected-value" …Run Code Online (Sandbox Code Playgroud) 我已经在我的Meteor项目车把帮手中:
Handlebars.registerHelper('isEq', function(v1, v2, options){
if(v1 === v2){
return options.fn(this);
}else{
return options.inverse(this);
}
});
Run Code Online (Sandbox Code Playgroud)
但更新到0.8,而且从车把后spacebars它不工作了-我在,现在我应该改变其他计算器话题发现Handlebars.registerHelper到UI.registerHelper,但它仍不能工作-任何人都知道如何正确地实施本作spacebars?
就像在标题中一样 - 例如我有一个方法DrawMe(what),我想允许在what参数等于其中一个值时运行此方法:{"house", "garden", "cat", "dog"}- 如果不是,则应停止此方法并应打印错误.有任何想法吗?
我想使用自定义样式表路径/stylesheets/stylesheet.css与nanoc一起使用,但nanoc不会在output文件夹中呈现css文件.这是我的规则:
compile '/stylesheets/' do
filter :css
end
compile '/images/*/' do
end
compile '*' do
if item.binary?
# don’t filter binary items
else
filter :haml
layout 'default'
end
end
route '/stylesheets/' do
'/stylesheets/stylesheet.css'
end
route '*' do
if item.binary?
# Write item with identifier /foo/ to /foo.ext
item.identifier.chop + '.' + item[:extension]
else
# Write item with identifier /foo/ to /foo/index.html
item.identifier + 'index.html'
end
end
layout '*', :haml
Run Code Online (Sandbox Code Playgroud)
它不起作用 - 任何人都知道问题出在哪里?它也只生成output/stylesheet/index.html包含我的样式表但放入我的html布局!:(
这是它的样子(output/stylesheet/index.html): …
javascript ×3
nanoc ×3
haml ×2
meteor ×2
ruby ×2
assets ×1
base64 ×1
c# ×1
canvas ×1
codeblocks ×1
cordova ×1
css ×1
django ×1
file-io ×1
iron-router ×1
jestjs ×1
jquery ×1
markdown ×1
meteor-blaze ×1
mocking ×1
nested-lists ×1
option ×1
pre ×1
python ×1
routing ×1
slice ×1
spacebars ×1
stylesheet ×1
unit-testing ×1
url-routing ×1
vue.js ×1
vuejs2 ×1