在玩游戏screeps.com时,我想计算构建所需身体的成本.请参阅下面的我的尝试,cfg.bodybodypart数组在哪里,例如[Game.ATTACK, Game.MOVE, Game.WORK, Game.CARRY, Game.MOVE]:
var buildCost = 0;
for(var bodypart in cfg.body){
switch(bodypart){
case "MOVE":
case "CARRY":
buildCost+=50;
break;
case "WORK":
buildCost+=20;
break;
case "HEAL":
buildCost+=200;
break;
case "TOUGH":
buildCost+=20;
break;
case "ATTACK":
buildCost+=80;
break;
case "RANGED_ATTACK":
buildCost+=150;
break;
}
console.log(bodypart + " costs " + buildCost);
}
Run Code Online (Sandbox Code Playgroud)
打印bodypart到控制台时,它显示索引(0,1,2,3,...),buildCost保持为0.
成本和零件在Screeps页面上描述.
问题
我使用nuxt 1.4,并使用Jest进行路由以进行单元测试。我的应用程序不会抛出错误,并且看起来运行良好。但是,当运行我的单元测试npm run unit(运行笑话)时,它将在终端中引发错误:[Vue warn]: Unknown custom element: <nuxt-link> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
预期
我希望它不会引发此错误,因为我的应用程序正在运行。
档案
package.json:
{
"name": "vue-starter",
"version": "1.0.0",
"description": "Nuxt.js project",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"precommit": "npm run lint",
"test": "npm run lint && npm run unit",
"unit": "jest",
"unit:report": …Run Code Online (Sandbox Code Playgroud) jsFiddle:http: //jsfiddle.net/PYeFP/
我有一个条形图设置,用于显示用户白天的行程数
tripVolume = dc.barChart("#trip-volume")
.width(980) // (optional) define chart width, :default = 200
.height(75) // (optional) define chart height, :default = 200
.transitionDuration(0) // (optional) define chart transition duration, :default = 500
.margins({ top: 10, right: 50, bottom: 30, left: 40 })
.dimension(tripsByDateDimension) // set dimension
.group(tripsByDateGroup) // set group
// (optional) whether chart should rescale y axis to fit data, :default = false
.elasticY(false)
// (optional) whether chart should rescale x axis to fit data, …Run Code Online (Sandbox Code Playgroud) 我正在使用vuelidate验证我的表单输入并使用vuetifyjs显示错误消息。我设法进行了基本的对象验证,并能够显示错误消息。
但是,当我验证集合时,在显示错误消息时遇到了问题。
问题
数据结构示例:
contact: {
websites: [
{
url: 'http://www.something.com',
label: 'Website',
}
]
}
Run Code Online (Sandbox Code Playgroud)
验证示例:
validations: {
websites: {
$each: {
url: {
url,
}
}
},
}
Run Code Online (Sandbox Code Playgroud)
示例模板:
<template v-for="(website, index) in websites">
<v-layout row :key="`website${index}`">
<v-flex xs12 sm9 class="pr-3">
<v-text-field
label="Website"
:value="website.url"
@input="$v.websites.$touch()"
@blur="$v.websites.$touch()"
:error-messages="websiteErrors"
></v-text-field>
</v-flex>
</v-layout>
</template>
Run Code Online (Sandbox Code Playgroud)
计算错误消息示例:
websiteErrors() {
console.log('websites',this.$v.websites) // contains $each
const errors = []
if (!this.$v.websites.$dirty) {
return errors
}
// Issue is that all of …Run Code Online (Sandbox Code Playgroud) crossfilter ×1
d3.js ×1
dc.js ×1
javascript ×1
jestjs ×1
nuxt.js ×1
screeps ×1
validation ×1
vue-router ×1
vue.js ×1
vuejs2 ×1
vuelidate ×1
vuetify.js ×1