设置 width: 100% height: 100%跟老师显示的不一样
来源:4-2 给小程序添加地图组件(下)
好奇宝宝c
2021-04-02 23:10:07
为什么设置了宽高100%左边显示的还有,不是应该啥都没了吗,我看老师的都没了,我index.js页面代码也都是复制的老师的,app.json里面的配置也跟老师的一样
相关代码:
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World from vscode',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
setting: {
skew: 0,
rotate: 0,
showLocation: false,
showScale: false,
subKey: '',
layerStyle: -1,
enableZoom: true,
enableScroll: true,
enableRotate: false,
showCompass: false,
enable3D: false,
enableOverlooking: false,
enableSatellite: false,
enableTraffic: false,
},
location: {
latitude: 31,
longitude: 120,
},
scale: 10,
markers: [
{
iconPath: "/resources/car.png",
id: 0,
latitude: 23.099994,
longitude: 113.324520,
width: 50,
height: 50
},
{
iconPath: "/resources/car.png",
id: 1,
latitude: 23.099994,
longitude: 114.324520,
width: 50,
height: 50
},
]
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs?color=blue'
})
},
onShow: function() {
console.log('lifecycle: index onShow')
},
onHide: function() {
console.log('lifecycle: index onHide')
},
onReady: function() {
console.log('lifecycle: index onReady')
},
onUnload: function() {
console.log('lifecycle: index onUnload')
},
onLoad: function () {
console.log('lifecycle: index onLoad')
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
},
onBtnTap: function() {
this.setData({
motto: 'button clicked'
})
}
})
相关代码:
{
"pages": [
"pages/index/index",
"pages/logs/logs",
"pages/test2/test2"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#FFD9EC",
"navigationBarTitleText": "租辆酷车",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
2回答
ccmouse
2021-04-06
好奇宝宝c
提问者
2021-04-03
算了无所谓了。 。
相似问题