break
1 | for(let i =0;i< 10;i++){ |
ref 和 reactive 一个针对原始数据类型,而另一个用于对象,这两个API都是为了给JavaScript普通的数据类型赋予响应式特性(reactivity)。
1 | const dataAsRefs = toRefs(data); |
1 | <template> |
子组件
1 | <!-- Form.vue --> |
父组件
1 | <!-- App.vue --> |
1 | <!-- Form.vue --> |
git pull是git fetch和git merge两个步骤的结合
vscode 的 sync 等于下面
1 | git pull origin someBranch |
几个思路:
1 | /* default link color is blue */ |
1 | <div class="parent"> |
flex order 或者 row-reverse 。 DOM 在后但显示“在前”。
1 | ul li:nth-child(-n+2) |
via https://stackoverflow.com/questions/1817792/is-there-a-previous-sibling-selector
via https://coolcssanimation.com/how-to-trigger-a-css-animation-on-scroll/
1 | var io = new IntersectionObserver(callback, option); |
1 | function query(selector) { |
1 | var intersectionObserver = new IntersectionObserver( |
观测 resize
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
scrollIntoView()
默认是
scrollIntoView(true)
也就是
scrollIntoView({block: “start”, inline: “nearest”})
scrollIntoView({block: “end”, inline: “nearest”})
behavior Optional
Defines the transition animation. One of auto or smooth. Defaults to auto.
block Optional
Defines vertical alignment. One of start, center, end, or nearest. Defaults to start.
inline Optional
Defines horizontal alignment. One of start, center, end, or nearest. Defaults to nearest.
1 | obj.scrollIntoView( |
1 | .container { |
1 | for (var i = 0; i < btns.length; i++) { |
1 | var iframe = document.getElementById("myFrame"); |
1 | function myFunction(x) { |
1 | <defs> |
1 | 'fill-color': ['interpolate-hcl', ['linear'], ['feature-state', 'population'], 0, 'red', 1e6, 'blue'] |
1 | 'fill-color': ['match', ['get', 'id'], |
1 | "icon-image": [ |
1 | this.map.setPaintProperty("somelayer", "fill-color", |
1 | const layers = [{ |
以下这个未测试!
1 | ['step', ['zoom'], |
1 | map.addLayer({ |
1 | "line-color": [ |
if (quakeID) {
map.removeFeatureState({
source: “earthquakes”,
id: quakeID
});
}
map.setFeatureState({
source: ‘earthquakes’,
id: quakeID,
}, {
hover: true
});
1 |
map.addLayer({
‘id’: ‘earthquakes-viz’,
‘type’: ‘circle’,
‘source’: ‘earthquakes’,
‘paint’: {
// The feature-state dependent circle-radius expression will render
// the radius size according to its magnitude when
// a feature’s hover state is set to true
‘circle-radius’: [
‘case’,
[‘boolean’,
[‘feature-state’, ‘hover’],
false
],
[
‘interpolate’, [‘linear’],
[‘get’, ‘mag’],
1, 8,
1.5, 10,
2, 12,
2.5, 14,
3, 16,
3.5, 18,
4.5, 20,
6.5, 22,
8.5, 24,
10.5, 26
],
5
],
‘circle-stroke-color’: ‘#000’,
‘circle-stroke-width’: 1,
// The feature-state dependent circle-color expression will render
// the color according to its magnitude when
// a feature’s hover state is set to true
‘circle-color’: [
‘case’,
[‘boolean’,
[‘feature-state’, ‘hover’],
false
],
[
‘interpolate’, [‘linear’],
[‘get’, ‘mag’],
1, ‘#fff7ec’,
1.5, ‘#fee8c8’,
2, ‘#fdd49e’,
2.5, ‘#fdbb84’,
3, ‘#fc8d59’,
3.5, ‘#ef6548’,
4.5, ‘#d7301f’,
6.5, ‘#b30000’,
8.5, ‘#7f0000’,
10.5, ‘#000’
],
‘#000’
]
}
});
````
via https://docs.mapbox.com/help/tutorials/create-interactive-hover-effects-with-mapbox-gl-js/
var aa = { “type”: “Polygon”,
“coordinates”: [
[
[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
}
var aa = { “type”: “Polygon”,
“coordinates”: [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
}
test.map.getSource(‘temp_line’).setData(aa)
{
type:’FeatureCollection’,
features:[
{
“geometry”: {
“type”: “MultiPoint”,
“coordinates”: [
[
108.91373500227928,
34.241324229728534
],
]
},
“type”: “Feature”,
}
]
}
1 | Array.prototype.push.apply(a, [1,2])) |
a.push(1, 2, 3);
1 | var arr = [1]; |
思路如下(console中有三个数据)
1 | function sleep(ms) { |
via https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep
其实是重建
1 | function setLayerSource (layerId, source, sourceLayer) { |
1 | const DEFAULTS = { |
直接字面量创建
1 | var objA = {}; |
new关键字创建
1 | var objB = new Object(); |
Object.create 创建
一个完整的版本
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": [ |