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

微信小程序中用WebStorm使用LESS

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

前提

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

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

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

Less環(huán)境

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

通過

npm install less -g

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

WebStorm的Less使用

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

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

可以參考自己其他文章

WebStorm:遇到的問題

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

直接wxss和 less的比較

我們先看下頁面

頁面很簡單

就只有一個 sky 套用 3個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的使用

我們簡單定義變量 和 方法以后

用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)對應(yīng)的wxss文件,也改變了,直接生成了可以讀取的文件

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

也不會出現(xiàn)對應(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ū)別,只是代碼寫起來更方便(建議機子配置可以的畫,開發(fā)別用微信提供的ide,效率太低)

less很強大,其他的地方,有時間再深入,

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

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

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

相關(guān)文章

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

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

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

    微信小程序 自己制作小組件實例詳解

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

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

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

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

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

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

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

    微信小程序 常用工具類詳解及實例

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

    ResizeObserver?API使用示例詳解

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

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

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

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

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

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

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

最新評論

平湖市| 屏东市| 樟树市| 云霄县| 左权县| 盐池县| 屯昌县| 塔河县| 万源市| 昌黎县| 桐城市| 微山县| 茶陵县| 淄博市| 元氏县| 丁青县| 镇雄县| 和平区| 广平县| 绩溪县| 文水县| 台东市| 鹿邑县| 古交市| 百色市| 霞浦县| 全椒县| 桐柏县| 克东县| 张家港市| 饶阳县| 玛纳斯县| 绥棱县| 丰都县| 肇源县| 黄陵县| 栖霞市| 江西省| 竹溪县| 股票| 连平县|