我目前正在使用D3.js并遇到了一个我似乎无法解决的问题.
我有一个CSV,其中有一个名为"Set"的列和一个名为"Year"的列.我想从这些列中提取值并将它们用作类名.这就是我现在拥有的......
var circle = svg.selectAll("circle")
.data(data)
.enter()
.append("circle")
.attr("class", function(d) {
if (d["Set"] == 1)
{
return "set-1";
}
if (d["Set"] == 2)
{
return "set-2";
}
});
Run Code Online (Sandbox Code Playgroud)
这完全正常,并为每个数据点提供一个类名.但是,当我尝试以下操作时,"Set"类名称被"Year"类名称覆盖.
var circle = svg.selectAll("circle")
.data(data)
.enter()
.append("circle")
.attr("class", function(d) {
if (d["Set"] == 1)
{
return "set-1";
}
if (d["Set"] == 2)
{
return "set-2";
}
.attr("class", function(d) {
if (d["Year"] == 2012)
{
return "2012";
}
if (d["Year"] == 2013)
{
return "2013;
}
});
Run Code Online (Sandbox Code Playgroud)
如何纠正这些代码,以便添加额外的类名而不是覆盖它们.
希望有人能提供帮助.
我面临一个非常奇怪的问题,如果具有受限权限的用户尝试登录我的网络应用程序,他们会看到以下错误:
Uncaught (in promise) undefined
但这不会发生在拥有最大权限的用户身上。
我认为问题是由重新路由引起的。如果用户没有 page_access 1,则路由到 /holidays。另一个奇怪的事情是这个错误只出现一次,也就是用户第一次登录的时候。如果页面刷新或用户导航到其他页面,它不会出现。
路由器.js
Vue.use(Router)
const router = new Router({
routes: [
{
path: '/',
name: 'dashboard',
component: Dashboard,
beforeEnter(to, from, next) {
if(localStorage.token) {
if(localStorage.page_access.indexOf('1') != -1 && localStorage.page_access != null) {
next('/holidays');
}
else {
next();
}
} else {
next('/login');
}
}
},
{
path: '/holidays',
name: 'holidays',
component: Holidays,
beforeEnter(to, from, next) {
if(localStorage.token) {
next();
} else {
next('/login');
}
}
},
],
mode: 'history'
})
router.beforeResolve((to, from, …Run Code Online (Sandbox Code Playgroud) 是否可以使 v-dialog 具有动态宽度?当前,默认情况下 v-dialog 具有动态高度,这使其根据内容的长度缩短和延长。
但这可以用宽度来完成吗?
我有一个包含 4 个选项卡的 v 对话框。其中 3 个选项卡不需要太大的宽度,但最后一个选项卡包含一个表格,所以我希望对话框尽可能地加宽,以满足表格的需求,然后在单击第一个时再次缩短3 个标签。
Vuetify v-dialog:https ://vuetifyjs.com/en/components/dialogs
How do I set a default value to a variable if array.find returns 'undefined'.
Here's the line that's causing me issues. In some instances this variable will populate but in others, it won't and in that case, I want it to default to 0.
this.statistics.creditAmount = response.data.find(t => t.paymentType == 'RF' && t.status == 1).amount || 0;
Run Code Online (Sandbox Code Playgroud) 如何重试Laravel Horizon 中所有失败的作业?似乎没有“全部重试”按钮,并且 artisan 命令不起作用,因为失败的作业未存储在表中。
javascript ×3
css ×2
vue.js ×2
async-await ×1
d3.js ×1
ecmascript-6 ×1
html ×1
laravel ×1
laravel-5 ×1
laravel-5.8 ×1
php ×1
promise ×1
svg ×1
vue-router ×1
vuetify.js ×1