我创建了一个需要存储并保留给另一个页面的对象数组。
对象数组类似于:
var cheese_array = [
{
name: "Chedder",
age: "34",
smelly: true
},
{
name: "Brie",
age: "4",
smelly: false
},
{
name: "Blue Stilton",
age: "13",
smelly: true
}
];
Run Code Online (Sandbox Code Playgroud)
但是当我使用JSON.stringify()它时,它不会对对象进行字符串化,而只会对数组进行字符串化。所以我最终得到了如下所示的数组:
[object Object], [object Object], [object Object]
Run Code Online (Sandbox Code Playgroud)
那么你如何在这个数组中字符串化这些对象。
编辑: 然后将此对象数组传递给类似于以下内容的点击函数:
$("#a-button").click(function() {
var cheese_arr_stringify = JSON.stringify(cheese_array);
sessionStorage.cheeseArray = cheese_arr_stringify;
if(sessionStorage.cheeseArray) {
window.location.href = "../";
}
});
Run Code Online (Sandbox Code Playgroud)
差不多,它设置cheese_arr_stringify为对象数组的字符串化版本。然后它将此字符串化代码设置为会话密钥。在此之后,一旦设置了 cheeseArray,它就会将它发送到一个目录。
我想在Angular2 CLI项目中使用Stylus而不是标准CSS.我已经浏览了一下,找不到任何关于如何设置它的可靠来源.
我一直在使用CSS在我的网站中玩弄各种形状,现在还可以,但是在操作它们时有时会有些烦人,因为例如三角形,它实际上是带有边框的矩形。
对于CSS中的形状创建指南,我正在使用有关CSS技巧的文章。
我想使用CSS,因为它的加载速度比使用图片的速度更快。
几天过去了,我偶然发现了SVG,我一直在网上看到它们,但从未研究过它们。因此,我想知道,使用SVG代替这些CSS“ hacks”来实现形状会更简单吗?找不到有关此特定主题的任何受污染的信息,因此,感谢您提供有关SVG的任何信息。(这些形状的宽度将为1000px +,因此为什么我不想使用图片...)
TL; DR:更好的方法- 跨浏览器/加载时明智 -希望在网页上具有形状时。我只是看着SVG在想这是否可行。
抱歉,下面是我目前正在使用的代码,以及我要实现的图像(不幸的是,设计图像的人并未提供设计代码,仅提供了图像) 。
源图像
我的代码 (抱歉,如果您不喜欢无礼)
<div class="arrow-wrap">
<div class="arrow">
<div class="arrow-text">
<h1>Services</h1>
<p>Learn more about our services by selecting one below</p>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
.arrow-wrap
overflow: hidden;
display: flex
justify-content: center
position: relative
z-index: 10
.arrow
width: 0
height: 0
border-style: solid
border-width: 150px 100vw 0 100vw
border-color: $dark transparent transparent transparent
position: relative
z-index: 1
display: flex
justify-content: center
.arrow-text
text-align: center
margin-top: -130px
white-space: …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的前端工作建立一个构建系统,虽然我遇到了一遍又一遍地循环处理文件的问题.这是我的js处理的问题,因为我不知道如何仅使用.min作为后缀来排除文件.
任务如下
return gulp.src(["!dev/js/*.min.js", "dev/js/*.js"])
.pipe(plumber())
.pipe(browserify())
.pipe(smaps.init())
.pipe(uglyify({preserveComments: "license"}))
.pipe(smaps.write())
.pipe(rename({suffix: ".min"}))
.pipe(gulp.dest(output_dir));
Run Code Online (Sandbox Code Playgroud)
虽然我发现它仍然以.min.js文件为目标,因为它们也被视为.js文件.我搞砸周围的这些通配符的几个不同的配置,但我一直与任务创建循环结束了example.min.js,然后example.min.min.js再example.min.min.min.js等.
那么,我怎样才能处理不包含.min前缀的文件?
我已经能够编辑CSS变量document.documentElement.style.setProperty("--text-color", "#333")但是,我无法使用jQuery重现这一点,.css()原型似乎只适用于已知的CSS属性.
以下是上述CSS变量的示例CSS.
:root {
--text-color: #888;
}
div {
color: var(--text-color);
}
Run Code Online (Sandbox Code Playgroud)