一个完整的版本
1 | import StarRating from 'vue-star-rating' |
1 | import InfoWindowContent from '../InfoWindowContent.vue' |
1 | // 添加Popup对象 |
一个完整的版本
1 | import StarRating from 'vue-star-rating' |
1 | import InfoWindowContent from '../InfoWindowContent.vue' |
1 | // 添加Popup对象 |
options.preserveDrawingBuffer
If true , the map’s canvas can be exported to a PNG using map.getCanvas().toDataURL() . This is false by default as a performance optimization.
1 | map.getCanvas().toDataURL() |
Returns an array of GeoJSON Feature objects representing visible features that satisfy the query parameters.
https://docs.mapbox.com/mapbox-gl-js/api/map/#map#queryrenderedfeatures
1 | // Find all features within a static bounding box |
1 | // Find all features within a bounding box around a point |
1 | // Query all rendered features from a single layer |
Returns an array of GeoJSON Feature objects representing features within the specified vector tile or GeoJSON source that satisfy the query parameters.
https://docs.mapbox.com/mapbox-gl-js/api/map/#map#querysourcefeatures
1 | // Find all features in one source layer in a vector source |
1 | // If an image with the ID 'cat' already exists in the style's sprite, |
1 | "icon-color": [ |
https://stackoverflow.com/questions/17964757/how-to-prune-delete-nodes-in-nested-tree-like-json
1 | var a = [ |
简单说,就是允许碰撞
1 | "icon-ignore-placement": true, // 不管下面 |
1 | var aa = { "type": "Polygon", |
最外面多一层
1 | var aa = { "type": "MultiPolygon", |
test.map.getSource(‘temp_polygon’).setData(aa)
1 | var aa = { |
1 | var aa = { |
1 | var clone = Object.assign({}, {a: 1, b: 2, c: 3}); |
这个不完美
1 | var clone2 = Object.assign({}, {a: 1, b: 2, c: 3}, {b: undefined}); |
1 | const x = {a: 1, b: 2, c: 3, z:26}; |
1 | const obj = { a: 1, b: 2, c: 3, d: 4 } |
lodash
1 | _.omit(x, 'b') |
package.json 的 eslintConfig(如果已经有 eslintrc.js )
1 | "rules": { |
1 | let a = {a:1,b:{c:{d:2}}} |
via https://www.samanthaming.com/tidbits/70-3-ways-to-clone-objects/
1 | const purchase = [ |
两头对齐
1 | Masks 9.99 |
1 | const bankNumber = '2222 2222 2222 2222'; |
类似滴:
deep copy (or deep clone): lodash _.cloneDeep, Ramda, a custom function, JSON.parse() / JSON.stringify(), and rfdc
For the best performance, the library rfdc (Really Fast Deep Clone) will deep copy about 400% faster than lodash’s _.cloneDeep
const a = new Object();
对象字面量
const a = {};
es5
const a = '123' const obj = { a:a }
es6
const a = '123' const obj = { a } // 属性从同名变量找
es5
`
const a = {
a:function(){
}
}
`
es6
`
const a = {
a(){
}
}
`
const skill = '安邦' const david =
文能${skill}
var heat = '50%'; var field = 'Rock and Roll'; var music = { [field.toLowerCase()]: heat } console.log(music); // Object {rock and roll: "50%"}
let music = { type: 'rock', heat: '50%' }; let { type, heat } = music; console.log(type, heat); // rock 50%
对象解构 重命名
let music = { type: 'rock', heat: '50%' } let { type: aaa, heat: bbb } = music; console.log(aaa, bbb); // rock 50%
let people = [20, 25, 30] let [young, oldYoung] = people; console.log(young, oldYoung) // 20 25