为什么win10玩lol崩溃玩Rest会崩

80后怀旧:我们为什么喜欢玩日本游戏?
发布时间: 11:30:37
作者:Nadia Oxford
虽然许多二三十岁的人在20世纪70年代末,80年代初的时候都首次接触了来自于美国掌机和电脑的游戏体验,但是不可否认的是,那时候任天堂的红白机(游戏邦注:任天堂在20世纪八九十年代发售的一种家庭主机)以及附带游戏都将我们带进了一个幻想世界中,在那里我们能够看到龙,机器人以及被囚禁的公主等形象,并且因为过度沉迷于这些游戏,我们还常常让家长们大伤脑筋。
Japanese games(from 1up)
日本在电子游戏领域的发展对于北美游戏产业着实是个致命的打击。甚至有好几年的时间,那些来自于英语国家的小孩都将日本与电子游戏牢牢地联系在一起,甚至夸张到很多人都在学习日语并希望能够到日本找工作以进一步接触当地的游戏产业。
电子游戏领域在过去10年的发展给我们带来了一些好消息,但是不幸的是,我们在日本的游戏产业中听到的却是坏消息。好消息是,越来越多来自全世界各地的天才开发者制作出了更多不一样且富有想象力的有趣的游戏。而坏消息是,除了任天堂的游戏,日本再也不愿意与世界分享他们的其它游戏财富。当美国,欧洲以及英国正在不断扩展自己的游戏产业并分享最棒的游戏理念时,日本却开始停滞不前,并逐渐封闭自己。
如果你是伴随着红白机,超级任天堂,世嘉Genesis以及Saturn或者索尼游戏机长大的话,那么你一定会对此感到遗憾吧。尽管现在的日本产业遭到许多质疑和批判,但是没有人能够否认他们过去,甚至是现在对于游戏发展的影响,而这也是其他国家不能匹敌的。
日本角色扮演游戏(RPG)
这里并不是说日本的电子游戏比西方国家的游戏优秀,或者哪一个国家的开发者强于其他国家。而是对于日本游戏来说有,它们拥有一些特征,或者说是完整的流派。就像我们会说“西方RPG”(WRPG)以及“日本RPG”(JRPG),而不会将WRPG分解为“法国RPG”或者“加拿大RPG”等。
事实上,快速比较JRPG和WRPG,我们便能够明显地看出这两种派别在游戏角色设计以及游戏规则中的差异,而这也是来自温哥华的26岁动画师Christi Sawyer所关注的一大问题。
她说道:“我会选择日本游戏是因为它们的角色设计和不同类型的游戏设置。虽然我也会考虑游戏派别以及我所喜欢的游戏类型,但是我会更加侧重我所喜欢的游戏设计。”
japanese game (from 1up)
有趣的是,日本角色扮演游戏深受西方角色扮演游戏(如《龙与地下城》)以及电脑角色扮演游戏(如《创世纪1》)的启发。美国的《勇者斗恶龙》以及日本的《最终幻想》都致力于创造出拥有视觉震撼力的卡通怪兽以及各种角色的角色扮演游戏。它们同样也都将人物属性按照一种容易理解的形式展现在玩家面前。即使是今天,当西方角色扮演游戏变得越来越复杂,甚至让玩家能够不受限制地在游戏中进行探索时,JRPG仍然提供给玩家非常有结构性的游戏环境,充满各种回合制战斗,甚至在玩家迷失方向时仍有人会站出来指明方向。
如今的市场对于大多数JRPG所带有的刻板结构表示质疑,而这些市场中更多的是对于西方角色扮演游戏的肯定。的确,这些质疑也并非莫须有。在一些JRPG中,游戏的挑战都是基于战斗,但是前提是玩家的级别必须与对手相匹配——《勇者斗恶龙1》便应用了这种战术,并且后来的游戏也很难摆脱这种机制。
虽然如此,不论是男孩还是女孩在漫无目的地玩了一圈西方角色扮演游戏后都能够在更加稳定且直接的JRPG世界中找到更多乐趣,而这也没有任何羞耻可言。
明亮的图像,动物角色
我们之所以会效仿日本那种以动物形象为主的游戏,是因为在20世纪90年代末,日本动画片在美国火到不行(游戏邦注:这在很大程度上得益于《宠物小精灵》这款游戏/动画片),所以那时美国任何一款基于现实事物而创造出来的游戏或者动画片都受到日本的影响——虽然这股趋势仍然存在着,但是比起早前的热潮可以说是已经慢慢冷却下来了。
宠物小精灵(from 1up)
早期我们在玩日本电子游戏时总会因为一些漫画家的艺术风格而兴奋不已,包括鸟山明,天野喜孝,宫本茂,小岛文美以及野村哲也。虽然近年来我们开始认为日本设计的游戏角色都是一些长得像女生的“男孩形象”,但是我们也知道这种说法不能用来涵括所有日本游戏。日本游戏美术设计师也因为多样性的风格而享负盛名,而且在我们知道这些美术设计师的名字之前,我们已经伴随着他们的作品逐渐长大了。
如果真的说当今日本游戏的美学欠缺了些什么,那也是因为游戏角色的设计者犹犹豫豫地不敢去做出尝试。因为不管怎么说,这个国家的游戏美术设计师都是非常有天赋的。虽然我们开玩笑说野村哲也只对拉链和皮带有兴趣,但是却不可否认他创造了像《最终幻想5》中的“Shadow”以及阴暗的刺客等优秀角色。
带来有趣与奇幻的体验
我们总是会开玩笑地说到日本总是在对外传输一些奇奇怪怪的东西,好吧,我想说说这背后的一些真相。想想你曾经在电子游戏中遇到的每一个古怪的东西以及不可思议的时刻。可以说这些稀奇古怪的东西有99%是源于日本游戏体验。
有时候因为不同语言间的翻译而会引起一些有趣的事,这也称作日式英语。对于讲英语的人来说,日语真的很难懂。有些角色对话间的差异性甚至会让那些英语老师抓狂,例如“赢家是你”(“A winner is you”,出现于任天堂的《Pro Wrestling》),“你输了”(”You fail it” ,Neo-Geo的《Blazing Star》)以及“你所有装备都归我们所有”( “All your base are belong to us”,世嘉至强驱动器的《Zero Wing》)等说法。有些网站存储了所有日式英语表达方式(如“”),有空时不妨看看这些有意思的内容。
来自日本电子游戏中的幽默感让玩家很难会去介意那些愚蠢的拼写错误(但随着翻译技巧的改进这种错误越来越少见了)。日本总是很擅于为玩家呈现一些疯狂的场景,设置和角色,而且整个过程中都能贯穿一种较为严肃的氛围,就像商人定期提交商业报告的那种感觉。换成其他国家模仿日本的做法去开发一款射击游戏,即一个首领朝着一群女学生开枪射击,我们肯定会感到恐惧和难过吧。但是同样情况下,日本游戏却能够很自然地让我们不会因为游戏中的任何可怕事件而心情低落。
我们来看看《块魂》(游戏邦注:日本Namco公司出品的一款非常有趣的PS2游戏):你的父亲因为酗酒而将月球给破坏了,而身为儿子的你为了弥补父亲的过世,携带着能吸住任何东西的“块”到地球上,借着滚动块将其它东西吸进来的方式而滚出大球,让这大球不断长大,并送上太空替代已被毁灭的月球。在游戏中,你的父亲是宇宙之王,头上带着毛巾卷,穿着一条非常紧身的裤子并炫耀自己的打扮。
在整个游戏产业中再也未出现类似的形象,如果日本并未完成这款游戏,那么我们也永远看不到类似游戏的出现。
我们喜欢玩日本电子游戏的另外一大原因,也是非常重要的一点便是:怀旧情愫。我们中的许多人都是伴随着一些明亮颜色头发以及装扮华丽的游戏角色长大,而再次接触这些角色能够让我们倍感亲切。
怀旧情愫(from 1up)
来自西雅图的一名实验医学研究生Chang Liu承认:“我是一个念旧的人。我喜欢小时候玩过的那些游戏,也就是掌机游戏,更直白地说就是日本游戏。”
“虽然随着年龄的增长,我慢慢远离了这些游戏,但是直到今年早些时候,当我发现很多来自日本的优秀游戏并未在美国发行,我才真正意识到自己对于日本游戏的感情,并且无奈地认为自己将不再是个游戏玩家了。”
吸引力和认知性也很重要,而我们也是因此逐渐趋向那些我们所赞许的事物。来自大西洋中部地区的一位网站设计者“rnn”表示:“我接触的第一款游戏是日本的一位亲戚送给我的,所以直到现在,我仍认为日本就是电子游戏的代名词。尽管我还不能明确自己是否喜欢游戏中的美术设计,但是可以肯定的是,美术设计是我选择游戏的首要标准。如果以艺术风格来说,比起《军团要塞》,我更喜欢《Professor Layton》或者《幽灵诡计》。”
我们喜欢日本
的确,对于日本游戏现在的存在感来说,我们不得不提到北美市场或者欧洲市场上越来越罕见的日本游戏作品。很难过的是,如今我们正踏上一个新的数据黑暗时期,而在这里我们只有真诚地祷告,祈祷日本优秀的游戏能够再次出现在世界市场上。2011年对于日本游戏的忠实粉丝来说是一个相对阴暗的一年,因为北美任天堂所有者取消了在当地市场发行一些角色扮演游戏的决定,如《異度之刃》,《最后的故事》以及《潘多拉之塔》。除此之外,像玩家期待已久的《洛克人传奇3》也因为资金不足以及缺乏创造性等理由而被扼杀在摇篮里了。
japanese game character(from 1up)
但是,在这些凄惨的情景下也有一些值得高兴的事。许多日本公司,如Square-Enix已经意识到东方游戏市场中存在的一些问题,而他们也决心努力去解决这些问题,让自己再次崛起。
当Square-Enix在2011年的E3游戏展上表现欠佳的情况下,Square-Enix一名高管在Twitter上写道:“日本游戏产业的衰落让我感到难过。而这一整周的时间我都在烦恼着该如何解决这个问题。”
同时,一些著名的日本游戏设计师,如Yuji Naka和Keiji Inafune也相继离开了那些刻板的公司结构束缚,自己组建独立的游戏工作室,重新做自己最喜欢的事:设计游戏。
暂且不提日本游戏产业现在所面临的麻烦,不管是过去还是现在,亦是未来,日本对于全世界游戏产业的贡献都是难以估量的。游戏无国界,我们对于东方游戏(即日本游戏)的热爱和激情永远不会随着时间的变化而变化,将会一直持续下去。(本文为游戏邦/编译,拒绝任何不保留版权的转载,如需转载请联系:游戏邦)
Why We Play Japanese Games
By: Nadia Oxford
Most 20- and- 30-somethings probably owe their first gaming experience to the tangle of American-made consoles and computers that blew through the late ’70s and early ’80s. But it was arguably Nintendo Entertainment System and its accompanying games that immersed us neck-deep in a fantasy worlds populated by dragons, robots, and princesses in peril — worlds we didn’t want to leave, much to our parents’ chagrin.
Japan’s contribution to video games gave the North American side of the industry a shot of adrenaline right in the heart. For years, kids in English-speaking countries associated Japan with video games (for better or worse), to the point that some of us were inspired to study the language and then look overseas for jobs in the industry.
The past decade has brought a lot of good news for video games in general, and some unfortunate news for Japan specifically. The good news is that talented game developers from around the world are making wicked contributions to our favorite pastime, and games have more imagination and variety than ever before as a result. The bad news is that Japan doesn’t seem to be sharing the rest of the industry’s prosperity, with the notable exception of Nintendo. While the United States, Europe, and the Commonwealth are all expanding outwards and sharing their best game ideas, Japan appears to be stagnating, and withdrawing into itself.
It’s a sad to watch this apparent breakdown if you grew up with the NES, the SNES, the Genesis and the Saturn/Playstation. Even though the Japanese side of the industry has been garnering a lot of criticism lately, no-one can deny that Japan brought — and still brings — a certain flavor to gaming that can’t be matched by any other country.
The Japanese RPG: An Alternative for the Easily Lost
That’s not to suggest Japan is better at making video games than Western countries, or that any one country developers superior games above any other. But there are specific traits, and even entire genres, that are exclusive to Japanese games. We talk about “Western RPGs” (WRPGs) and “Japanese RPGs” (JRPGs), but we don’t break down WRPGs by defining them as “French RPGs” or “Canadian RPGs.”
In fact, a quick comparison of the JRPG and WRPG genres will immediately yield large differences between character designs and gameplay formulas, a point that is not overlooked by Christi Sawyer, a 26-year-old animator from Vancouver.
“I usually look for [Japanese games] because of character designs and [the] different style of gameplay,” she says. “I still give consideration to the game genres I enjoy of all styles, but I usually look for a design I like to look at.”
Interestingly, Japanese role-playing games were heavily inspired by Western role-playing modules like Dungeons & Dragons, and computer RPGs such as Ultima I. DragonQuest and Final Fantasy aimed to make role-playing games more visually appealing with animated monster and character art. They also streamlined pounds of character stats into one easy-to-understand status screen. And even today, while Western RPGs have grown increasingly complex and generally let players explore their surroundings with minimal restrictions or limitations, some of us still look to JRPGs for a more structured game environment built around turn-based battles and townspeople who will kindly point us in the right direction when we get lost.
The rigid structure that still dominates most JRPGs is often criticized in a market that’s warming up to Western role-playing games. Granted, some of that criticism is warranted. In some JRPGs, the game’s challenge is dependent on fighting battles until your characters’ levels match the bad guy’s — a tactic that was ushered in with the very first Dragon Quest game, and seems to have a difficult time saying goodbye.
Nevertheless, guys and gals who often wind up feeling aimless in Western RPGs can find a lot of enjoyment in the more stable, straightforward world of the JRPG, and there’s no shame in that.
Bright Graphics, Anime Heroes
There’s also nothing wrong with turning to Japanese games for our fix of anime-style graphics. When the popularity of anime exploded in America in the late ’90s (thanks in no small part to the Pokemon games and anime), every game and cartoon created through the Aughts seemed to borrow a little bit of Japan’s influence — a trend that still persists, even though the initial anime boom has since cooled down.
But video games that are made in Japan boast an art style that typically goes beyond artists slapping a pair of doe-eyes on a character and calling it a day. Playing through the earliest generations of video games has warmed us to the styles of Japan’s most iconic manga artists, including Akira Toriyama, Yoshitaka Amano, Shigeru Miyamoto, Ayami Kojima, and (love him or hate him) Tetsuya Nomura. As quickly as we tend to dismiss Japanese-designed characters as featureless “androgynous boys” lately, we know in our hearts that’s an unfair generalization. Japan’s game artists boast a wide variety of styles, and we grew up loving those artists’ works long before we had the opportunity to learn their names.
If there’s a problem with the aesthetics in recent Japanese games, it’s because character designers have, for one reason or another, been hesitant to experiment. Otherwise, the country’s game artists are supremely talented. For all the jokes we make about Nomura’s passion for zippers and belts, we forget he designed the likes of Shadow, Final Fantasy VI’s shrouded, bad-ass assassin.
Bringing the Funny — and the Bizzare
We also make jokes about Japan’s tendency to export wackiness, and, well, there’s some truth behind that. Think back to every bizarre, incomprehensible moment you’ve encountered in a video game. Chances are excellent that ninety percent of those baffling experiences are owed to a game that originated in Japan.
Sometimes, the laughs are doled out unintentionally through bad translations, A.K.A. instances of “Engrish.” Japanese can be extremely tricky for English-speakers to decode. These discrepancies can make for character dialogue that would cause our English teachers to shrivel up and die, though geek culture continues to applaud greats like, “A winner is you” (Pro Wrestling, NES), “You fail it” (Blazing Star, Neo-Geo) and, of course, “All your base are belong to us” (Zero Wing, Sega Mega Drive). Entire websites have been assembled to archive gaming’s best examples of Engrish (such as ), and are a joy to visit when you’re in the dumps.
But the sense of humor that comes from Japanese video games is hardly restricted to laughing at Japan when it makes a goofy spelling mistake (which is becoming less of an occurrence because of improved translation efforts). Japan has a remarkable talent for presenting players with crazy plots, settings, and characters with a kind of seriousness that’s typically reserved for a businessman handing in a report on a Wednesday morning. If any other country in the world tried to develop a shoot-em-up parody game with a boss fight against a subtlety horrifying stack of schoolgirls, we’d probably bristle with douche chills. But it’s hard not to be amused by the straightforward way in which Japan presents its weirdest games.
Consider the plot for Katamari Damacy: Your drunken father destroys all the stars in the sky, so you have to roll up some crud on Earth to make new ones. Oh, and your father is the King of the Universe, wears a paper towel roll on his head, and wears tight, tight pants that show off his package as if it ain’t no thing.
There’s nothing else like that in the industry, and if Japan ever drops out of game development completely, there never will be again.
Power Up: Nostalgia
There’s one more reason why we play Japanese video games, and it’s a big one: Nostalgia. Many of us grew up with colorful, spikey-haired heroes, and turning back to those characters grants us a rush of warmth and familiarity.
“I’m a creature of habit,” admits Chang Liu, a Laboratory Medicine graduate living in Seattle. “I like to play the games I played as a child and since I am a console gamer that means Japanese games.
“I [do] step out of my comfort zone,” says Liu, “but I hadn’t realized how much playing video games meant playing Japanese video games until earlier this year when it seemed lots of highly anticipated games from Japan weren’t coming out in the U.S. and I felt my time as a gamer was coming to an end.”
Attraction and recognizably are also factors, as some of us drift towards what we know best. “My first games were all hand-me-downs from a Japanese relative,” says “rnn,” a website designer who lives in the mid-Atlantic region, “so at least until very recently, in my mind Japan equals video games, and video games equal Japan. Also I don’t decide if I like a game based on aesthetics, but aesthetics do determine whether or not I try a game in the first place. While I can appreciate the art style of say, the Team Fortress games, they don’t appeal to me instantly like Professor Layton or Ghost Trick.”
We Love Japan
Indeed, the dwindling presence of Japan’s games brings back a series of unpleasant memories that connect to a time when seemingly too few of Japan’s best works were localized for the North American and/or European markets. It’s sad to think that we might be heading into a new digital Dark Age, where we have to fall on our knees and pray that Japan’s best and brightest games will lap up on our shores eventually. 2011 hasn’t been a particularly cheerful year for fans of Japanese fare, as North American Wii owners have had to do without localizations for RPGs like Xenoblade, The Last Story, and Pandora’s Tower. Meanwhile, other projects, like the long-awaited Mega Man Legends 3, were canceled outright over financial and creative concerns.
But there’s a bright side to all this seeming doom and gloom. Major Japanese companies like Square-Enix realize there’s a problem with the Eastern side of the game market, and they’re not about to let themselves fade into obscurity.
“[T]he decline in Japanese titles was almost humiliating,” Square-Enix senior executive officer remarked on on Twitter after Square-Enix’s poor Japanese showing at E3 2011. “This has been a week where I worried daily about how we can fix this.”
Meanwhile, famous Japanese game designers like Yuji Naka and Keiji Inafune have left behind the rigid Japanese corporate structure to form independent game studios and get back to doing what they love most: Designing games.
Regardless of its current troubles, Japan’s contributions to the game industry have been, and continue to be, priceless. And even though a person’s love for gaming doesn’t have to be restricted by borders, it’s safe to say that many of us will always find the time and passion to glance eastward and take note of what’s going on.()
CopyRight Since 2010 GamerBoom All rights reserved &&闽ICP备&号-1如果你会了Sass,你就会了ES2015 - 推酷
如果你会了Sass,你就会了ES2015
如果你会了Sass,你就会了ES2015!...虽然不是全部,但也有很多惊人的相似之处!当学习
,ES2015(以前被称为ES6)时,碰到了一些让我立刻想到Sass的特性。
Sass语言和ES2015
非常有表现力(intentionally?),最初于2006年发布,使用Ruby编写,也模仿了Ruby的语法和一些语言场景(decisions?)。至于其他特性,分号和花括号在
实现了,使Sass感觉更像(也使他能兼容)CSS。这些变化,再加上Sass核心的可扩展性和SassScript的实用性,意味着这是一个新的兼容CSS的强大编程语言。写样式变得更有力并且编程在设计师和视觉开发中更受欢迎。不幸的是,
每个Sass语言场景(decision?)的背后都有很多思考,其中很重要的一点就是准确性高于定制性(也就是
Sass不允许像
那样自定义属性)。新的ECMAScript 2015 标准(ES2015)在2015年六月正式发布,为JavaScript添加了大量新的,实用的特性,使其更清晰并且更易用。
然而大多数浏览器仍然不支持ES2015,你可以使用像
这样的转换器将代码转换成兼容性好的ES5代码。预编译步骤(当然,我知道他们不完全相同)只是这两种语言相似部分的开始。
作为一个Sass开发者,你可能没注意到很多Sass的特性现在在ES2015中已经实现了,对于JavaScript开发者,反之亦然。
模板字符串插值
这个ES2015特性让我第一次意识到这两种规范多么的相似。两种字符串插值几乎完全相同(这让我很开心)。事实上,ES2015引入了一个 很赞的 基于反引号的字符串模板。
这意味着你不再需要为了普通字符串拼接和静态DOM操作(许多情况下)而引入其他的模板引擎了。这真是太棒了!还提高了代码间的一致性。
对于插值的定义真的很烂。看下面的例子,本质上只是建立字符串变量到其真实值的引用的一种方式。
看上去就像这样 —— 不用这么写:
&First Name: & + fName + &\nLast Name: & + lName
只需要这样:
First Name: ${fName}
Last Name: ${lName}`
这 恰好 和Sass很像!好好想想,在Sass中,变量是这样的: $varName ,因为 $ 已经被占用了,所以使用 # 来表示插值。
`variable: ${varName}`
&variable: #{$varName}&
字符串插值在写Sass的混合和向DOM插入内容(例如:使用CSS的 content 属性)时超级好用。我们会在后面的例子中发现它在Sass开发中多么重要和常用。
默认参数在编写灵活的函数(在Sass中叫混合)时特别有用。我经常在Sass中使用它,为没定义任何参数的函数或混合提供预定义的默认值,当你在使用时就可以选择传入自己定义的值或者空着它并且使用默认值。现在,你在JavaScript中也可以使用这些特性!
声明函数时,你可以在参数列表中为变量在右侧声明一个默认参数(像Sass一样):
function sayHello(recipient = &beautiful&){
return &Hello& +
sayHello();
sayHello(&sunshine&);
/*console*/
& Hello beautiful
& Hello sunshine
@mixin showOutline($color: #f00) {
outline: 1px solid $
@include showOutline()
@include showOutline(#ccc)
/*css ouput*/
outline: 1px solid #f00;
outline: 1px solid #
在Sass中同样需要注意任何带有默认值的变量一定要跟在没有默认值的变量的后面(也就是声明函数/混合时参数的顺序)。如果你在想为何要遵守这个规则,可以很容易发现如果一个含有默认值的参数后面跟着一个不含默认值的参数(必填参数)时,如果你不传入必填参数就会崩溃。
关于函数/混合参数中另一个相似的地方,ES2015的rest参数和Sass中的参数列表参数类型也很像!定义函数时,rest参数(参数列表)也必须位于一串参数的最后一个。
函数定义中Rest参数通过
( ... )创建,你可能发现了展开运算符也可以用于数组中的可迭代对象,但是和在函数 定义 中使用时表现有点
在传入参数的长度不确定时就可以使用参数列表或rest参数。举个例子,Sass中 box shadow 和 gradients 是很常用的。在Javascript中,rest参数通过在参数名前加 ... 表示,Sass中则是在参数后面:
function PrintMe(firstArg, ...theRest) {
console.log(firstArg, theRest);
PrintMe('Hello', 'You', 'Look', 'Nice');
/*console*/
& Hello [&You&, &Look&, &Nice&]
@mixin funCircle($size, $gradient...) {
border-radius: 50%;
background: radial-gradient($gradient);
.entrancing {
@include funCircle(50px, blue 10%, red 80% ,pink);
/*css output*/
.entrancing {
height: 50
border-radius: 50%;
background: radial-gradient(blue 10%, red 80%, pink);
上面两个例子中,参数列表/rest参数的值在没被任何处理的情况下会被拼在一起返回。
&FOR-OF&循环
ES2015中数组
和Sass中的循环结构非常像。ES2015中引入了 for-of 循环。也许你很好奇他和 for-in 有什么不同?
for-of 循环迭代器引用的是数组元素的值而不是索引。这样更灵活而且你可以直接遍历数据(数组中的值)而不是对象的属性(像 for-in 那样)。由于这个限制, for-in 的问题之一就是你不能从一个 for-in 循环中跳出或者返回。
在Sass中,任何循环的工作方式都如同 for-of 一样而不是 for-in ,无论是 map 还是 list ,或者lists中的 list 。虽然语法不同( each-in vs for-of )循环机制是相同的:
let colorArray = [&red&, &yellow&, &green&];
for (let color of colorArray) {
console.log(color);
$colorList: &red&, &yellow&, &green&;
@each $color in $colorList {
如果我使用 for (let color in colorArray) (用 in 代替 of )结果将变成 0 , 1 , 2 而不是 red , yellow , green 。这两种循环方法最大的不同就在这里。
Sass中的 @debug 语句(如上所示)和 console.log 很像,不过,你也可以使用 @return 这个方法。而且,这些循环在生成多个类和样式时(后面的部分会有例子)很常用。
ECMAScript2015中提供了一种新的数据结构:maps!Map非常适合用于
并且能够通过 key: value 对形式获取它们的元素。它和对象有什么不同?好问题。对象中的 “key” 总是会被转换成字符串。而
中的 key 可以是任何类型,不会被转换成字符串。对于混合值类型和在运行时之前就知道所有值的情况下仍然应该使用对象,不过map在其他方面真的很有用。
Maps也是可迭代的!所以你可以像下面展示的那样(在 for-of 循环中)去获取值(Sass中也可行!)。这有一个简单的例子:
let colorMap = new Map();
colorMap.set(&primary&, &red&);
colorMap.set(&secondary&, &yellow&);
colorMap.set(&tertiary&, &green&);
for (let [key, value] of colorMap) {
console.log(`key: ${key}, value: ${value}`);
/*console*/
& key: primary, value: red
& key: secondary, value: yellow
& key: tertiary, value: green
$colorMap: (
&primary&: &red&,
&secondary&: &yellow&,
&tertiary&: &green&
@each $key, $value in $colorMap {
.color--#{$key} {
color: #{$value};
/*css output*/
.color--primary {
.color--secondary {
.color--tertiary {
你可能已经发现我在这个例子中使用了插值语法(比如 #{$value} 而不是简单的 $value )。因为使用后者时,Sass将在结果中输出字符串:(比如: color: &green& 而不是 color: green ),这在CSS中将无法生效。
Sass提供了几个像 map-get 函数这样的细节实现,通常用来获取map的值, map-has-key 对调试非常有用:
@if map-has-key($colorMap, $color) {
$color: map-get($colorMap, $color);
@if type-of($color) != color {
@error &Invalid color name: `#{$color}`.&;
JavaScript的 map 也有
方法!在Javascript中是简单的 get() 而不是 map-get() :
var colorMap = new Map();
colorMap.set(&primary&, &red&);
colorMap.get(&primary&);
你可以在Sass(和JavaScript)中对 map 进行删除,合并,压缩( zip ?)等操作。这真的是个组织代码的好方法,将对象信息转化成颜色指数。(?)
最后但并非最不重要的,ES2015引入了类(当然,不是真正的类,而是基于原型的让我们假装写类的语法糖)。还有和类一起引入的继承!(听起来很熟悉?)
它们的使用方法和Sass的 @extend 指令非常相似,JavaScript中的继承允许创建一个继承其父类方法和属性的新的类(然后, super() 方法能调用新类父级的方法。例如 class Corgi extends Dog ), Corgi 能获取 Dog 的 bark() 方法通过 super.bark() 。
你也可以在构造函数中执行此方法来实例化所有父类的方法。这让 extends 的工作方式和 @extend 更像!
很困惑?看代码更容易些:
class Dog {
constructor(name) {
this.name =
bark(words) {
console.log(`WOOF!!! ${words} WOOF!`);
class Corgi extends Dog {
constructor() {
waddle() {
// corgi waddle
//Steve is a cori
let steve = new C
//Steve can bark like a Dog
steve.bark('I like bacon!')
//AND Steve can waddle, too!
/*console*/
& WOOF!!! I like bacon! WOOF!
.plain-link {
font-weight: 600;
text-decoration:
border-bottom: 2px dotted currentC
.pink-link {
@extend .plain-
.blue-link {
@extend .plain-
/*css output*/
.plain-link, .pink-link, .blue-link {
font-weight: 600;
text-decoration:
border-bottom: 2px dotted currentC
.pink-link {
.blue-link {
color: blue
对于Sass中的混合来说 @extend 和 @include 有一个很关键的不同。我们使用 @extend 获取了来自 .plain-link 的全部样式,而且这些样式可以在每个继承该类的元素间共享 —— 像JavaScript的例子中从父类获取的JavaScript方法一样。然后我们可以使用额外的不同属性(Sass例子中的 color ,JavaScript例子中的 waddle 方法),他们在父类中不可用,但是在继承他们的子类中可用。
为了满足大家的好奇心,我在
写过关于 @extend 的全部知识和我如何系统地在Sass中使用他们。
虽然这些都是不完整的比较,但
,尤其是一些ES2015的新特性。
希望你喜欢这篇文章并从中学到了新东西!可以在
提出建议确保我的文章更好理解!
》所译,整个译文带有我们自己的理解与思想,如果译得不好或有不对之处还请同行朋友指点。如需转载此译文,需注明英文出处:
前端开发,音乐,动漫,技术控,喜欢折腾新鲜事物,以不断学习的态度,在前端的路上走下去。
已发表评论数()
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
主题不准确
没有分页内容
图片无法显示
视频无法显示
与原文不一致

我要回帖

更多关于 崩坏3好玩吗 的文章

 

随机推荐