JS設置類名
添加類名或者移除類名來進行實現,在類裡面書寫控制項位置的樣式;
JS設置style的方式
把控制項位置的樣式寫在style裡面
『貳』 微信小程序怎麼獲取組件的屬性
可以把組件的屬性寫到data-xxx裡面 當點擊的時候獲取
比如
<buttonsize="mini"data-button_size="mini"bindtap="click"><button>
然後在點擊事件裡面獲取button-size就可以了
『叄』 微信小程序前端能在一個組件中插入另一個組件嗎
當然可以,組件嵌套,使用solt
『肆』 開發中怎樣在小程序中添加天氣組件
首先分析製作的思路:
1.在app.json文件的pages數組里加上main文件夾和template(模板)文件夾的路徑。
2.在main.js文件中,在onLoad()函數中調用loadInfo()函數。
3. 自定義獲取位置的函數loadInfo(),調用wx.getLocation,用於獲取當前的緯度(latitude)和經度(longitude)。在loadInfo()函數中接著調用loadCity()函數。
4. 自定義獲取城市的函數loadCity(),調用wx.request,在「網路地圖開放平台」網站中注冊自己的AK,通過獲取城市信息的網址(http://api.map..com/geocoder/v2/?ak=自己的ak&location=緯度值,經度值&output=json)實現當前城市名稱的獲取。
在loadCity()函數中接著調用loadWeather()函數。
5.自定義獲取天氣的函數loadWeather(),根據已有的城市名稱,通過獲取天氣信息的網址(http://wthrcdn.etouch.cn/weather_mini?city=城市名)實現天氣信息的數據獲取。
6.在main.wxml文件中,未來天氣部分通過import調用了自定義模板文件itemtpl.wxml。
然後分析項目中文件的源碼。
app.json文件的代碼如下:
{
"pages":[
"pages/main/main",
"pages/template/itemtpl",
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "天氣",
"navigationBarTextStyle":"black"
}
}
main.wxml的代碼如下:
<view class='cont'>
<!-- 今日天氣-->
<view class='today'>
<view class='info'>
<view class='tempe'>{{today.wen}}°C</view>
<view class='weather'>{{today.todayInfo.type}}{{today.todayInfo.fengxiang}}</view>
<view>溫馨提示:{{today.ganmao}}</view>
<view class='city'>{{city}}</view>
</view>
</view>
<!-- 未來天氣-->
<import src="../template/itemtpl"/>
<view class='future'>
<block wx:for="{{future}}">
<template is="future-item" data="{{item}}"/>
</block>
</view>
</view>
main.wxss文件的代碼如下:
/**/
.cont{
font-size:30rpx;
width:100%;
height:100%;
}
.today{
padding:50rpx 0 0 0;
height:50%;
}
.info{
padding:20rpx;
background:rgba(0,0,0,.8);
line-height: 1.5em;
color:#eee;
}
.tempe{
font-size:90rpx;
text-align: center;
margin:30rpx 0;
}
.weather{
text-align: center;
}
.city{
font-size:40rpx;
color:#f60;
text-align: right;
margin: 30rpx 10rpx 0 0;
}
.future{
display:flex;
flex-direction: row;
height:100%;
padding:20rpx 0 20rpx 10rpx;
background:rgba(0,0,0,.8);
text-align: center;
margin:50rpx 0 70rpx 0;
color:#eee;
}
.future-item{
min-height: 100%;
width:160rpx;
margin: 0 10rpx;
border:solid 1px #f90;
padding:10rpx 0 0 0;
line-height:2em;
}
main.js文件的代碼如下:
//
Page({
data: {
// weatherData:''
city:"" ,
today:{},
future:{},
},
onLoad: function () {
this. loadInfo();
},
//自定義獲取位置
loadInfo:function(){
var page=this;
wx.getLocation({
type: 'gcj02', //返回可以用於wx.openLocation的經緯度
success: function (res) {
var latitude = res.latitude
var longitude = res.longitude
console.log(latitude, longitude);
page.loadCity(latitude, longitude);
}
})
} ,
//自定義獲取城市
loadCity: function (latitude, longitude){
var page = this;
wx.request({
url: 'http://api.map..com/geocoder/v2/?ak=自己的AK &location=' + latitude + ',' + longitude + '&output=json',
header: {
'content-type': 'application/json'
},
success: function (res) {
console.log(res);
var city=res.data.result.addressComponent.city;
city=city.replace("市","");
page.setData({
city:city
});
page.loadWeather(city);
}
})
},
//自定義獲取天氣
loadWeather: function (city) {
var page = this;
wx.request({
url: 'http://wthrcdn.etouch.cn/weather_mini?city=' + city,
header: {
'content-type': 'application/json'
},
success: function (res) {
console.log(res);
var future=res.data.data.forecast;
var todayInfo=future.shift();
var today=res.data.data;
today.todayInfo=todayInfo;
page.setData({
today:today,
future:future,
});
}
})
}
})
itemtpl.wxml的代碼如下:
<!-- 模板文件-->
<template name="future-item">
<view class="future-item">
<view>{{item.date}}</view>
<view>{{item.type}}</view>
<view>{{item.fengxiang}}</view>
<view>{{item.low}}</view>
<view>{{item.high}}</view>
</view>
</template>
至此,案例製作完成。
『伍』 小程序loading組件在哪
安卓系統改變的方法如下: 依次打開 系統設置-應用程序-選擇默認的那個程序(這里就選擇微信)-清除默認值即可。
『陸』 微信小程序 怎麼 選擇組件 做操作
微信小程序怎麼選擇組件,怎麼操作,我們可以通過以下方式:
一、常規代碼式
一般有技術實力的公司開發小程序是依照微信官方的代碼形式開發,這種方法優點就是,製作出的小程序界面、樣式排列各不相同,功能也比較豐富。但是一般中小型傳統企業並不具備這種開發實力。
原因:a、因為沒有實力的專業開發人員;
b、沒有太充足的開發資金提供;
c、對微信小程序未來發展和互聯網的發展認知不夠。
二、專業的第三方微信小程序開發公司
這類企業都有專門的技術團隊和豐富的開發經驗,商家只要把需求提供給公司,然後跟技術進行交流一下,把你的想法和需求說明,就可以開始了,而且這種開發方式開發價格較低,一般根據功能也就幾千,貴的話也就是一兩萬既可以實現。
『柒』 微信小程序組件demo在哪
解決方案資源管理器,在視圖下拉菜單里
『捌』 小程序怎麼組件開發
要有ES6 基礎.
css js 基礎.
根據小程序官方的組件文檔.
把每一個可以復用的功能設計成通用的. 然後創建成組件 調用使用.
細節太多. 可以追問
『玖』 小程序 哪些組件可覆蓋在原生組件上
級別相同的,可以覆蓋。位置一致、放在前端,就可以覆蓋