我有一个数组["0","1","2"],我需要创建使其成为
["0","1","2","0","1","2"的函数].我写了克隆函数:
arr = [0, 1, 2];
arr.clone = function() {
var b = [];
for (var i = 0; i < arr.length; i++) {
b.push(arr[i]);
}
var c = b.concat(b);
return c;
}
arr.clone();
Run Code Online (Sandbox Code Playgroud)
我做得对吗?也许有更好或更短的方法克隆元素?
我的项目使用 webpack。我有两个入口点:第一个用于带有 CSS 模块的 CSS 文件,第二个用于全局 css 文件。Main.css 不是从项目中的任何文件导入的,所以我为它创建了一个特殊的入口点。
const extractStylesCss = new ExtractTextPlugin('styles.css');
entry: {
'main': ["./src/index.tsx"],
'styles': "./src/main.css"
},
module: {
loaders: [
{
test: /^.*\.css$/,
exclude: [
path.join(__dirname, 'src/main.css')
],
loader: extractStylesCss.extract(
"style",
`css?modules&importLoaders=2&localIdentName=[local]___[hash:base64:5]___${pjson.version}!typed-css-modules!postcss?pack=pure&sourceMap=inline`
)
},
{
test: /main\.css$/,
loader: extractStylesCss.extract('style', 'css!postcss?pack=pure&sourceMap=inline')
},
]
},
plugins: [
extractStylesCss
],
output: {
path: path.join(__dirname, "/docs"),
filename: "[name].js"
}
Run Code Online (Sandbox Code Playgroud)
我只需要一个输出文件——styles.css。我知道 ExtractTextPlugin 为每个入口点生成一个包,但是否有可能获得一个文件?
我正在编写我的第一个IO应用程序.我有我的班级animation,我为我的按钮注册了一个动作
class animation {
var view: UIView!
init(var viewLink:UIView) {
self.view = viewLink
let buttonNext = UIButton.buttonWithType(UIButtonType.System) as UIButton
buttonNext.frame = CGRectMake(200, 250, 100, 50)
buttonNext.addTarget(self, action: "nextActionButton:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(buttonNext)
}
}
class ViewController: UIViewController {
private var animClass: animation?
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
animClass = animation(viewLink: self.view)
}
func nextActionButton(sender:UIButton!) {
println('rrr')
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个错误:
NSForwarding: warning: object 0x7fd820c94c00 of class 'animation.animation' does not implement methodSignatureForSelector: -- …