第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

融合這2個(gè)元素

融合這2個(gè)元素

慕慕森 2022-06-09 16:33:09
我不知道如何融合我在 ternaire 嘗試過的這兩部分代碼,但它沒有用if(marge[i].cas_v)    dps_cote.push({        x: i,        label: cote[i].x,        y: cote[i].y,        color: 'green',        indexLabelFontColor : "red",        indexLabelFontWeight: "bold",        indexLabel: marge[i].cas_v.toString()    });// CAS_V = NULLelse    dps_cote.push({        x: i,        label: cote[i].x,        y: cote[i].y,        color: 'green',        indexLabelFontColor : "red",        indexLabelFontWeight: "bold",        indexLabel: ""    });
查看完整描述

3 回答

?
慕森卡

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超8個(gè)贊

您可以嘗試以下方法


dps_cote.push({

        x: i,

        label: cote[i].x,

        y: cote[i].y,

        color: 'green',

        indexLabelFontColor : "red",

        indexLabelFontWeight: "bold",

        indexLabel: marge[i].cas_v?marge[i].cas_v.toString():""

    });


查看完整回答
反對(duì) 回復(fù) 2022-06-09
?
慕婉清6462132

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超2個(gè)贊

let object = {

    x: i,

    label: cote[i].x,

    y: cote[i].y,

    color: 'green',

    indexLabelFontColor : "red",

    indexLabelFontWeight: "bold",

}

if (marge[i].cas_v) {

    object.indexLabel = marge[i].cas_v.toString();

    dps_cote.push(object);

} else {

    dps_cote.push(object);

}


查看完整回答
反對(duì) 回復(fù) 2022-06-09
?
慕容708150

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超4個(gè)贊

所有的值都是用任意值定義的,以便提供一個(gè)有效的答案。

  1. 首先聲明和/或定義變量

  2. 然后流控制,如條件if/else if/else和/或三元let x = 0 > y ? z : a

  3. indexLabel由于具有兩個(gè)可能值之一,請(qǐng)避免重寫像定義兩次的對(duì)象那樣的代碼。如果您練習(xí)#1,那么重復(fù)的代碼膨脹就不會(huì)成為問題。

三元組的不同之處if/else if/else在于它就像一個(gè)表達(dá)式:

let iL = marge[i].cas_v ? marge[i].cas_v.toString() : "";

/* 

if `marge[i].cas_v` exists then `iL` is `marge[i].cas_v.toString()`

otherwise it is `""`

*/

obj.indexLabel = iL;

// whatever `iL` ends up to be -- its assigned to `obj.indexLabel` 

演示

/* 

if i = 0 then indexLabel: "11"

if i = 1 then indexLabel: "121"

if i = 2 then indexLabel: "14641"

*/

let i = 0;

let cote = [{x: 0, y: 0}, {x: 1, y: 0}, {x: 0, y: 1}];

let marge = [{cas_v: 11}, {cas_v: 121}, {cas_v: 14641}];

let dps_cote = [];

let obj = {

  x: i,

  label: cote[i].x,

  y: cote[i].y,

  color: 'green',

  indexLabelFontColor: "red",

  indexLabelFontWeight: "bold",

  indexLabel: ""

};


let iL = marge[i].cas_v ? marge[i].cas_v.toString() : "";


obj.indexLabel = iL;


dps_cote.push(obj);


console.log(dps_cote);


查看完整回答
反對(duì) 回復(fù) 2022-06-09
  • 3 回答
  • 0 關(guān)注
  • 94 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)