我有一个这样的逻辑:是用户是V2使用用户到url中subHeaderRouter.router.如果用户未启动this.openModal:
<router-link
v-for="subHeaderRouter in subHeaderRouters"
:to="subHeaderRouter.router"
@click="handleOpenModal()">
</router-link>
handleOpenModal () {
if (this.IsV2User) return
this.openModal('changeUserType', 'user.changeUserType')
}
Run Code Online (Sandbox Code Playgroud)
我现在唯一需要做的就是停止:to用户不是V2.怎么做到这一点?
我有一个Vuex数组(this.buildings).在将其转换为api的有效负载之前,我无法直接对其进行变异,因此我尝试使用以下方法克隆它slice():
const buildingsPayload = this.buildings.slice()
buildingsPayload.forEach((building, index) => {
building.index = index
})
Run Code Online (Sandbox Code Playgroud)
但是我仍然得到Do not mutate vuex store state outside mutation handlers.错误.
这样做的正确方法是什么?
我试过这个:
:root {
--primary-color: $black
}
$secondary-color = "lighten(%s, 20%)" % var(--primary-color)
Run Code Online (Sandbox Code Playgroud)
(我从这里拿来的:如何在 calc 中使用 Stylus 变量?)
我没有收到任何错误。但是,$secondary-color不渲染任何颜色。
这样做的最佳方法是什么?
结果是这样的:
background-color: lighten(var(--primary-color), 20%) 所以我认为有些东西渲染得不好。
我正在遵循基于此项目(官方 Vue Webpack 模板)的这些说明。
这就是我所做的:
包.js:
"scripts": {
"dev": "node build/dev-server.js",
"dev-alt": "node build/dev-server.js && set arg=alt&&webpack"
},
Run Code Online (Sandbox Code Playgroud)
webpack.base.config.js:
// npm run dev-alt in the terminal
console.log('ARGS:', process.env.arg)
Run Code Online (Sandbox Code Playgroud)
然而ARGS:输出undefined.
这样做的正确方法是什么?
我想只选择<buttons>父母拥有display: block并排除<buttons>父母拥有的父母display:none.
有没有办法实现这个目标?
我曾经遇到过UglifyJS for Webpack和ES6模块的问题:
来自UglifyJs的static/js/vendor.6ccd9e38979a78765c7a.js中的错误Unexpected token:name(features)[./ node_modules/pica/lib/mathlib.js:19,0] [static/js/vendor.6ccd9e38979a78765c7a.js:39003, 6]
我读到Webpack插件的新测试版支持ES6:
https://github.com/webpack-contrib/uglifyjs-webpack-plugin
new webpack.optimize.UglifyJsPlugin({
uglifyOptions: {
ie8: false,
ecma: 8, // I also tried 7 and 6
parse: {},
mangle: {
properties: {
// mangle property options
}
},
output: {
comments: false,
beautify: false
},
compress: {},
warnings: true
}
}),
Run Code Online (Sandbox Code Playgroud)
但是,现在我又收到了另一个错误:
来自UglifyJs的static/js/vendor.6ccd9e38979a78765c7a.js中的错误Unexpected token:name(features)[static/js/vendor.6ccd9e38979a78765c7a.js:39003,6]
可能是什么问题呢?
我想做这个: log(variableOrFunction)
能够产生这个:variableOrFunction: actualValue.
我试过这个:
export const log = (value) => {
console.log('' + value + ':', value)
console.log(value)
}
Run Code Online (Sandbox Code Playgroud)
但我得到了这个: [object Object]:
这样做的正确性是什么?
我正在使用$q一个方法来获取一个对象数组.我也有一个方法getItems,它使用这个promise(all).
我all在底部第二次用来做东西$scope.list.代码必须包含在内部,all().then(function() { ... }因此它只在$scope.list准备好时触发.
var all = function() { return $q.all([service.getAllItems()]) }
var getItems = function() {
all().then(function(value) {
$scope.list = JSON.parse(value)
}, function(reason) {
$scope.result = reason
})
}
getItems()
all().then(function() {
// do stuff with $scope.list
}
Run Code Online (Sandbox Code Playgroud)
这几乎可以.有时第一次all完成,有时第二次完成.所以有时候$scope.list有对象,有时它是空的.
如何创建仅在all获取对象数组时触发的新promise ?
我有两个函数:一个将文件转换为dataUrl,另一个函数返回一个带有结果的promise:
fileToDataURL(file) {
var reader = new FileReader()
return new Promise(function (resolve, reject) {
reader.onload = function (event) {
resolve(event.target.result)
}
reader.readAsDataURL(file)
})
}
getDataURLs (target) {
// target => <input type="file" id="file">
return Promise.all(target.files.map(fileToDataURL))
}
Run Code Online (Sandbox Code Playgroud)
target.files.map返回:TypeError: target.files.map is not a function.H
如何修改,getDataUrls以便返回带有dataUrls的数组?
我正在尝试自动下载这样的 blob:
blobGeneratingFunction.then(blob => {
// blob => Blob(3797539) {size: 3797539, type: "image/png"}
let file = new Blob([blob], { type: 'application/octet-stream' })
file.name = 'test.png'
file.download = 'test.png'
let blobURL = URL.createObjectURL(file)
window.location.href = blobURL
})
Run Code Online (Sandbox Code Playgroud)
name或属性都download无法设置文件名,现在是:
f486177d-6f5e-4f96-91a9-8df08e7d9da0
如何正确设置文件名?