应用(2)——

1.豆瓣 电影评星

//wxml
用的wx:for="{{6}}"
//wxss
.film-list{
width:100%;
white-space:nowrap;
}
.film-item{
display:inline-block;
width:200rpx;
padding:0 12rpx;
}

2.豆瓣 文字过长省略号处理

.film-name{
    white-space:nowrap;
    overflow:hidden;
    text-flow:ellipsis;
}

3.JS 里的promise
官方:
new Promise( funciton(resolve, reject) {...} );

var isLiForget = false; //是否生日送了礼物
var getCloth = new Promise(fucntion (resolve, reject){
      if(!isLiFroget){ //没忘记
            var cloth = {
            color: 'red',
            price: '$20'
      };
      resolve(cloth); //得到衣服
      }else{
            var err = new Error("forgot the promise"); //忘了
            reject(err);
      }
});
 //调用Promise
var testFn = function(){
      getCloth.then(function(fulfilled){
            console.log(fulfilled);
      }).catch(function(rejected){
            console.log(rejected.message);
      });
}
testFn();

4.将功能加在异步操作之后(豆瓣——上拉加载的细节处理——10:29)

loadListData(){ 
      return content...  //content是一个异步操作loadListData的内容,给加一个renturn可以实现目的
}

this.loadListData().then => (() => {  //在loadListData之后执行setData
      this.setData({
            showLoading:false
      })
})
posted @ 2020-12-10 16:39  巴伐利亚药水哥  阅读(37)  评论(0)    收藏  举报