true && number !== boolean
true && number !== boolean
bug
let result = ``;
// section, name ? create text, compute center point : no need render text
// feature, labelPoint ??? show text
// if (type === `section` && name) {
// if (type === "section" && name) {
// 🐛 true && number !== boolean
if (type === "section" && name.length ? true : false) {
// log(`绑定的选区 properties`, JSON.stringify(feature.properties, null, 4));
// fillColorReverser(fill);
// const areaUuid = `area` + uuid.slice(7);
const ticketArea = {
id,
activityEventId,
ticketCategoryId,
desc,
name,
floor,
sort,
status,
};
const areaProps = JSON.stringify(ticketArea);
// areaprops 🐛 areaProps auto convert to lowercase bug / xyzUFO="bug"
result = `
<polygon stroke="${stroke || ''}" fill="${fill || polygonFillColor}" points="${points}" center='${center}' areaprops='${areaProps} uuid="${uuid}"></polygon>
<text x="${x || ''}" y="${y || ''}" fill="${textFillColor}" uuid="${areaUuid}">${name}</text>
`;
} else {
result = `
<polygon stroke="${stroke || ''}" fill="${fill || polygonFillColor}" points="${points}" center='${center}' uuid="${uuid}"></polygon>
`;
}
error
type = "section";
"section"
name = `贵宾区`;
"贵宾区"
type === "section" && name
"贵宾区"
type === "section" & name
0
type === "section" & name.length
1
type === "section" && name.length
3
type === "section"
true
name.length
3

OK
type === "section" && (name.length ? true : false)
// true
type === "section" && name.length > 0
// true

本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/12427223.html
未经授权禁止转载,违者必究!

浙公网安备 33010602011771号