map组件无法显示marker?
发布于 4 年前 作者 fanxiulan 5465 次浏览 来自 问答

代码如下:

import React, { useState } from 'react'

function Main() {
    console.log(window.$$global.latitude)
    console.log(window.$$global.longitude)
    const [markers, setMarkers] = useState([
        {
            id: 0,
            latitude: window.$$global.latitude,
            longitude: window.$$global.longitude,
            width: '50px',
            height: '50px',
            // zIndex: 10,
            // iconPath: './[email protected]'
            iconPath: 'https://i.loli.net/2020/04/24/kLTiDMEtgl9ySnX.png'
        }
    ])
    return (
        <wx-map
            latitude={window.$$global.latitude}
            longitude={window.$$global.longitude}
            layer-style='1'
            style={{
                width: '100vw',
                height: '100vh'
            }}
            markers={markers}
        ></wx-map>
    )
}

export default Main

经纬度没问题,可显示不出来

1 回复

又试了一下,基本传数组的这几个东西都显示不出来。。。是我的用法不对吗?

回到顶部