最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序中用WebStorm使用LESS

 更新時(shí)間:2017年03月08日 17:14:28   作者:dodo_lihao  
這篇文章主要介紹了微信小程序中用WebStorm使用LESS的相關(guān)資料,需要的朋友可以參考下

前提

自己前端不熟悉,很多都需要練習(xí)

網(wǎng)上找了一個(gè)css的demo, 放到微信小程序后,可以運(yùn)行

圖片很大,沒有弄,加載可能有點(diǎn)慢(不相關(guān)的,就不扯了)

Less環(huán)境

Less需要nodejs的npm
nodejs的環(huán)境這里略了
自己百度

通過

npm install less -g

安裝好 less
(沒有用過的,可以理解為 maven的庫(kù), gradle庫(kù),pods的庫(kù))

WebStorm的Less使用

先關(guān)聯(lián)對(duì)應(yīng)的less

當(dāng)然,對(duì)應(yīng)的wxss文件,在webstorm中的顯示,

可以參考自己其他文章

WebStorm:遇到的問題

這里,只要?jiǎng)?chuàng)建less文件,就會(huì)自動(dòng)生成對(duì)應(yīng)的wxss文件了(當(dāng)然,寫好保存less文件,會(huì)自動(dòng)刷新wxss文件,很方便吧)

直接wxss和 less的比較

我們先看下頁(yè)面

頁(yè)面很簡(jiǎn)單

就只有一個(gè) sky 套用 3個(gè)cloud 類

view class="container">
 <view class="sky">
  <view class="clouds_one"> </view >
  <view class="clouds_two"> </view >
  <view class="clouds_three"> </view >
  <view class="clouds_three"></view>
 </view>

</view>

再看看css

.sky {
 height: 480px;
 background: #007fd5;
 position: relative;
 overflow: hidden;
 animation: sky_background 50s ease-out infinite;
}
.sky .clouds_one {
 background: url("../../resources/cloud/cloud_one.png");
 position: absolute;
 left: 0;
 top: 0;
 height: 100%;
 width: 300%;
 animation: cloud 50s linear infinite;
 transform: translate3d(0, 0, 0);
}
.sky .clouds_two {
 background: url("../../resources/cloud/cloud_two.png");
 position: absolute;
 left: 0;
 top: 0;
 height: 100%;
 width: 300%;
 animation: cloud 75s linear infinite;
 transform: translate3d(0, 0, 0);
}
.sky .clouds_three {
 background: url("../../resources/cloud/cloud_three.png");
 position: absolute;
 left: 0;
 top: 0;
 height: 100%;
 width: 300%;
 animation: cloud 120s linear infinite;
 transform: translate3d(0, 0, 0);
}
@keyframes cloud {
 0% {
 left: 0;
 }
 100% {
 left: -200%;
 }
}

我們發(fā)現(xiàn)有很多重復(fù)的地方

功能不難,但是占了70行,并且很難復(fù)用

修改的畫,還要看里面的邏輯

修改也不方便

Less的使用

我們簡(jiǎn)單定義變量 和 方法以后

用less 大體是這樣的

@dodo-out-height : 480px; //@dodo-out-height : 480rpx;
@dodo-bg-sky : #007fd5;
@dodo-img-url-clouds_one : "../../resources/cloud/cloud_one.png";
@dodo-img-url-clouds_two : "../../resources/cloud/cloud_two.png";
@dodo-img-url-clouds_three : "../../resources/cloud/cloud_three.png";

.sky {
 height: @dodo-out-height;
 background: @dodo-bg-sky;
 position: relative;
 overflow: hidden;
 animation: sky_background 50s ease-out infinite;
}
.sky .clouds_one {
 .dodo_clouds(@url:@dodo-img-url-clouds_one, @time: 50s)
}
.sky .clouds_two {
 .dodo_clouds(@url:@dodo-img-url-clouds_two, @time: 75s)
}
.sky .clouds_three {
 .dodo_clouds(@url:@dodo-img-url-clouds_three, @time: 120s)
}
.dodo_clouds (@url: @dodo-img-url-clouds_one, @height: 100%, @width: 300%, @time: 100s){
 background: url(@url);
 position: absolute;
 left: 0;
 top: 0;
 height: 100%;
 width: 300%;
 animation: cloud @time linear infinite;
 transform: translate3d(0, 0, 0);
}
@keyframes cloud {
 0% {
 left: 0
 }
 100% {
 left: -200%
 }
}

保存后,

我們發(fā)現(xiàn)對(duì)應(yīng)的wxss文件,也改變了,直接生成了可以讀取的文件

和之前直接寫的文件沒有太大區(qū)別

也不會(huì)出現(xiàn)對(duì)應(yīng)的變量和方法

.sky {
 height: 480px;
 background: #007fd5;
 position: relative;
 overflow: hidden;
 animation: sky_background 50s ease-out infinite;
}
.sky .clouds_one {
 background: url("../../resources/cloud/cloud_one.png");
 position: absolute;
 left: 0;
 top: 0;
 height: 100%;
 width: 300%;
 animation: cloud 50s linear infinite;
 transform: translate3d(0, 0, 0);
}
.sky .clouds_two {
 background: url("../../resources/cloud/cloud_two.png");
 position: absolute;
 left: 0;
 top: 0;
 height: 100%;
 width: 300%;
 animation: cloud 75s linear infinite;
 transform: translate3d(0, 0, 0);
}
.sky .clouds_three {
 background: url("../../resources/cloud/cloud_three.png");
 position: absolute;
 left: 0;
 top: 0;
 height: 100%;
 width: 300%;
 animation: cloud 120s linear infinite;
 transform: translate3d(0, 0, 0);
}
@keyframes cloud {
 0% {
 left: 0;
 }
 100% {
 left: -200%;
 }
}

預(yù)覽下:

也沒有區(qū)別,只是代碼寫起來更方便(建議機(jī)子配置可以的畫,開發(fā)別用微信提供的ide,效率太低)

less很強(qiáng)大,其他的地方,有時(shí)間再深入,

感覺less好用在于它的復(fù)用性 :)

簡(jiǎn)單demo源碼:http://xiazai.jb51.net/201703/yuanma/weapp-start-master(jb51.net).rar

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

  • JavaScript編程通過Matlab質(zhì)心算法定位學(xué)習(xí)

    JavaScript編程通過Matlab質(zhì)心算法定位學(xué)習(xí)

    這篇文章主要為大家介紹了JavaScript編程中通過Matlab質(zhì)心算法來定位的算法學(xué)習(xí),有需要的朋友可以借鑒參考下,希望能夠有所幫助
    2021-10-10
  • 微信小程序 自己制作小組件實(shí)例詳解

    微信小程序 自己制作小組件實(shí)例詳解

    這篇文章主要介紹了微信小程序 自己制作小組件實(shí)例詳解的相關(guān)資料,自己制作小組件在項(xiàng)目中應(yīng)用,需要的朋友可以參考下
    2016-12-12
  • JavaScript 反射學(xué)習(xí)技巧

    JavaScript 反射學(xué)習(xí)技巧

    這篇文章主要給大家分享的是JavaScript 的反射學(xué)習(xí)技巧,主要是區(qū)別在于所有的函數(shù)對(duì)象屬性過于復(fù)雜,而且額外增加可能會(huì)導(dǎo)致程序行為不合理,所以擴(kuò)展 Reflect 函數(shù)來專門對(duì)函數(shù)對(duì)象處理調(diào)用方法,構(gòu)造對(duì)象,獲取或者設(shè)置屬性等相關(guān)操作。下面一起進(jìn)入文章內(nèi)容吧
    2021-10-10
  • 一看就懂的JavaScript適配器模式圖解及使用示例

    一看就懂的JavaScript適配器模式圖解及使用示例

    這篇文章主要為大家介紹了JavaScript適配器模式圖解及使用示例分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-12-12
  • 微信小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)

    微信小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)

    這篇文章主要介紹了微信小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下
    2017-05-05
  • 微信小程序 常用工具類詳解及實(shí)例

    微信小程序 常用工具類詳解及實(shí)例

    這篇文章主要介紹了微信小程序 常用工具類詳解及實(shí)例的相關(guān)資料,需要的朋友可以參考下
    2017-02-02
  • ResizeObserver?API使用示例詳解

    ResizeObserver?API使用示例詳解

    這篇文章主要為大家介紹了ResizeObserver?API使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • Skypack布局前端基建實(shí)現(xiàn)過程詳解

    Skypack布局前端基建實(shí)現(xiàn)過程詳解

    這篇文章主要為大家介紹了Skypack布局前端基建過程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • JS實(shí)現(xiàn)layui?table篩選框記憶功能

    JS實(shí)現(xiàn)layui?table篩選框記憶功能

    這篇文章主要介紹了JS實(shí)現(xiàn)layui?table篩選框記憶功能,本案例放入本地緩存的方式,使用MutationObserver實(shí)現(xiàn)監(jiān)控點(diǎn)擊事件,需要的朋友可以參考下
    2022-01-01
  • 小程序開發(fā)踩坑:頁(yè)面窗口定位(相對(duì)于瀏覽器定位)(推薦)

    小程序開發(fā)踩坑:頁(yè)面窗口定位(相對(duì)于瀏覽器定位)(推薦)

    這篇文章主要介紹了小程序開發(fā)頁(yè)面窗口定位,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04

最新評(píng)論

丰原市| 长垣县| 宝应县| 潜江市| 武城县| 潍坊市| 林州市| 鲁山县| 高陵县| 台北市| 治县。| 抚顺市| 双牌县| 鄂伦春自治旗| 金沙县| 邵阳县| 饶河县| 澄迈县| 晋中市| 延寿县| 宝清县| 新郑市| 青海省| 德昌县| 五大连池市| 禹州市| 田林县| 库车县| 惠东县| 图们市| 博罗县| 富锦市| 高台县| 蕉岭县| 涞水县| 鹿泉市| 随州市| 阜康市| 平利县| 泸州市| 宜春市|