1. Path problem
Add "/" before the path to start from the system root directory
If there is no prefix, you need to fill in the correct path.
Paths in require are currently found to be correct relative paths.
2. The map component draws points asynchronously
When the map component is constructed,
markers
=
"{{markers}}"
These markers must be assigned before the component is constructed, otherwise they cannot be rendered
A workaround is to add an id
haslocation:false,
value true after getting markers
Then the map component adds wx:if
<
view
wx:if
=
"{{haslocation}}">
<
map
id
=
"map4select"
longitude
=
"{{longitude}}"
latitude
=
"{{latitude}}"
markers
=
"{{markers}}"
scale
=
"20"
style
=
"width:{{map_width}}px;height:{{map_height}}px"
bindregionchange=
"regionchange"
controls=
"{{controls}}">
</
map
>
</
view
>
</
view
>
但是这样存在一个问题,请求超时或者失败时,地图加载不出来。
3.展开运算符
微信小程序给的模版传入数据的例子里面
<template is="msgItem" data="{{...item}}"/>
...是什么意思呢,查询得知是ES6的展开运算符,具体参考https://blog.csdn.net/chauncywu/article/details/73060918
按照这个理解的话,加上...展开item后传入的就应该是item内的数据,访问时就可以不用item.attr这样的格式了。不加...的话,就需要item.attr这样访问。