91aaa在线国内观看,亚洲AV午夜福利精品一区二区,久久偷拍人视频,久久播这里有免费视播

<strong id="fvuar"></strong>

  • <sub id="fvuar"><dl id="fvuar"><em id="fvuar"></em></dl></sub>

    1. 千鋒教育-做有情懷、有良心、有品質(zhì)的職業(yè)教育機(jī)構(gòu)

      手機(jī)站
      千鋒教育

      千鋒學(xué)習(xí)站 | 隨時隨地免費(fèi)學(xué)

      千鋒教育

      掃一掃進(jìn)入千鋒手機(jī)站

      領(lǐng)取全套視頻
      千鋒教育

      關(guān)注千鋒學(xué)習(xí)站小程序
      隨時隨地免費(fèi)學(xué)習(xí)課程

      當(dāng)前位置:首頁  >  技術(shù)干貨  > kbone高級-使用rem

      kbone高級-使用rem

      來源:千鋒教育
      發(fā)布人:qyf
      時間: 2022-09-15 15:20:37 1663226437

        kbone 沒有支持 rpx,取而代之的是可以使用更為傳統(tǒng)的 rem 進(jìn)行開發(fā)。使用流程如下:

        1、用法

        1.1 修改 webpack 插件配置

        在 mp-webpack-plugin 這個插件的配置中的 global 字段內(nèi)補(bǔ)充 rem 配置。

        module.exports = {

        global: {

        rem: true,

        },

        // ... other options

        }

        1.2 在業(yè)務(wù)代碼里就可以設(shè)置 html 的 font-size 樣式了,比如如下方式:

        window.onload = function() {

        if (process.env.isMiniprogram) {

        // 小程序

        document.documentElement.style.fontSize = wx.getSystemInfoSync().screenWidth / 16 + 'px'

        } else {

        // Web 端

        document.documentElement.style.fontSize = document.documentElement.getBoundingClientRect().width / 16 + 'px'

        }

        }

        1.3 在業(yè)務(wù)代碼的樣式里使用 rem。

        .content {

        width: 10rem;

        }

        PS:這個特性只在基礎(chǔ)庫 2.9.0 及以上版本支持。

        2、案例

        在 kbone-advanced 目錄下創(chuàng)建 05-rem 目錄,本案例在這個目錄下完成。

        2.1 創(chuàng)建 package.json

        cd 05-rem

        npm init -y

        編輯 package.json:

        {

        "name": "01-env",

        "version": "1.0.0",

        "description": "",

        "main": "index.js",

        "scripts": {

        "build": "rimraf dist/web && cross-env NODE_ENV=production webpack --config build/webpack.config.js --progress --hide-modules",

        "mp": "cross-env NODE_ENV=production webpack --config build/webpack.mp.config.js --progress --hide-modules"

        },

        "dependencies": {

        "add": "^2.0.6",

        "vue": "^2.5.11"

        },

        "browserslist": [

        "> 1%",

        "last 2 versions",

        "not ie <= 8"

        ],

        "devDependencies": {

        "babel-core": "^6.26.0",

        "babel-loader": "^7.1.2",

        "babel-preset-env": "^1.6.0",

        "cross-env": "^5.0.5",

        "css-loader": "^0.28.7",

        "file-loader": "^1.1.4",

        "html-webpack-plugin": "^4.0.0-beta.5",

        "mini-css-extract-plugin": "^0.5.0",

        "optimize-css-assets-webpack-plugin": "^5.0.1",

        "stylehacks": "^4.0.3",

        "vue-loader": "^15.7.0",

        "vue-template-compiler": "^2.6.10",

        "webpack": "^4.29.6",

        "webpack-cli": "^3.2.3",

        "mp-webpack-plugin": "latest"

        },

        "keywords": [],

        "author": "",

        "license": "ISC"

        }

        安裝依賴包:

        npm install

        2.2 配置 webpack

        在 05-rem/build 目錄下創(chuàng)建 webpack.config.js,內(nèi)容如下:

        var path = require('path')

        var MiniCssExtractPlugin = require('mini-css-extract-plugin')

        const webpack = require('webpack')

        const { VueLoaderPlugin } = require('vue-loader')

        const HtmlWebpackPlugin = require('html-webpack-plugin')

        module.exports = {

        mode: 'production',

        entry: {

        index: path.resolve(__dirname, '../src/main.js'),

        },

        output: {

        path: path.resolve(__dirname, '../dist/web/'),

        publicPath: './',

        filename: '[name].js'

        },

        target: 'web',

        module: {

        rules: [

        {

        test: /\.css$/,

        use: [

        MiniCssExtractPlugin.loader,

        'css-loader'

        ],

        }, {

        test: /\.vue$/,

        loader: 'vue-loader',

        },

        {

        test: /\.js$/,

        use: {

        loader: 'babel-loader',

        options: {

        presets: ['env']

        }

        },

        exclude: /node_modules/

        },

        {

        test: /\.(png|jpg|gif|svg)$/,

        loader: 'file-loader',

        options: {

        name: '[name].[ext]?[hash]'

        }

        }

        ]

        },

        resolve: {

        extensions: ['*', '.js', '.vue', '.json']

        },

        plugins: [

        new webpack.DefinePlugin({

        'process.env.isMiniprogram': false, // 注入環(huán)境變量,用于業(yè)務(wù)代碼判斷

        }),

        new MiniCssExtractPlugin({

        filename: '[name].css'

        }),

        new VueLoaderPlugin(),

        new HtmlWebpackPlugin({

        filename: 'index.html',

        chunks: ['index'],

        template: path.join(__dirname, '../index.html')

        }),

        ]

        }

        2.3 創(chuàng)建 main.js

        在 01-env/src 目錄下創(chuàng)建 main.js,內(nèi)容如下:

        import Vue from 'vue'

        import App from './App'

        window.onload = function() {

        if (process.env.isMiniprogram) {

        // 小程序

        document.documentElement.style.fontSize = wx.getSystemInfoSync().screenWidth / 16 + 'px'

        } else {

        // Web 端

        document.documentElement.style.fontSize = document.documentElement.getBoundingClientRect().width / 16 + 'px'

        }

        }

        new Vue({

        el: '#app',

        render: h => h(App)

        })

        2.3 創(chuàng)建 App.vue

        在 05-rem/src 目錄下創(chuàng)建 App.vue,內(nèi)容如下:

      <template>

        <div class="title">

          hello, {{info}}!

        </div>

      </template>

       

      <script>

      export default {

        computed: {

          info() {

            if (process.env.isMiniprogram) {

              return 'miniprogram'

            } else {

              return 'web'

            }

          }

        }

      }

      </script>

       

      <style lang="css">

      .title {

        font-size: 1rem;

        color:brown;

      }

      </style>

        2.4 編寫入口文件 index.html

        在項目根目錄下創(chuàng)建 index.html,內(nèi)容如下:

      <!DOCTYPE html>

      <html lang="en">

        <head>

          <meta charset="utf-8">

          <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no,minimal-ui, viewport-fit=cover" />

          <meta content="yes"name="apple-mobile-web-app-capable"/>

          <meta content="black"name="apple-mobile-web-app-status-bar-style"/>

          <meta name="format-detection"content="telephone=no, email=no" />

          <title>vue</title>

          <style type="text/css">

            #app {

              font-family: 'Avenir', Helvetica, Arial, sans-serif;

              -webkit-font-smoothing: antialiased;

              -moz-osx-font-smoothing: grayscale;

              text-align: center;

              color: #2c3e50;

              margin-top: 60px;

            }

          </style>

        </head>

        <body>

          <div id="app"></div>

        </body>

      </html>

        2.5 Web端效果預(yù)覽

        npm run build

      圖片3

        2.6 創(chuàng)建 webpack.mp.config.js

        在 05-rem/build 目錄下創(chuàng)建 webpack.mp.config.js,內(nèi)容如下:

        const path = require('path')

        const webpack = require('webpack')

        const MiniCssExtractPlugin = require('mini-css-extract-plugin')

        const { VueLoaderPlugin } = require('vue-loader')

        const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');

        const TerserPlugin = require('terser-webpack-plugin')

        const MpPlugin = require('mp-webpack-plugin') // 用于構(gòu)建小程序代碼的 webpack 插件

        const isOptimize = false // 是否壓縮業(yè)務(wù)代碼,開發(fā)者工具可能無法完美支持業(yè)務(wù)代碼使用到的 es 特性,建議自己做代碼壓縮

        module.exports = {

        mode: 'production',

        entry: {

        'app': path.resolve(__dirname, '../src/main.mp.js')

        },

        output: {

        path: path.resolve(__dirname, '../dist/mp/common'), // 放到小程序代碼目錄中的 common 目錄下

        filename: '[name].js', // 必需字段,不能修改

        library: 'createApp', // 必需字段,不能修改

        libraryExport: 'default', // 必需字段,不能修改

        libraryTarget: 'window', // 必需字段,不能修改

        },

        target: 'web', // 必需字段,不能修改

        optimization: {

        runtimeChunk: false, // 必需字段,不能修改

        splitChunks: { // 代碼分隔配置,不建議修改

        chunks: 'all',

        minSize: 1000,

        maxSize: 0,

        minChunks: 1,

        maxAsyncRequests: 100,

        maxInitialRequests: 100,

        automaticNameDelimiter: '~',

        name: true,

        cacheGroups: {

        vendors: {

        test: /[\\/]node_modules[\\/]/,

        priority: -10

        },

        default: {

        minChunks: 2,

        priority: -20,

        reuseExistingChunk: true

        }

        }

        },

        minimizer: isOptimize ? [

        // 壓縮CSS

        new OptimizeCSSAssetsPlugin({

        assetNameRegExp: /\.(css|wxss)$/g,

        cssProcessor: require('cssnano'),

        cssProcessorPluginOptions: {

        preset: ['default', {

        discardComments: {

        removeAll: true,

        },

        minifySelectors: false, // 因為 wxss 編譯器不支持 .some>:first-child 這樣格式的代碼,所以暫時禁掉這個

        }],

        },

        canPrint: false

        }),

        // 壓縮 js

        new TerserPlugin({

        test: /\.js(\?.*)?$/i,

        parallel: true,

        })

        ] : [],

        },

        module: {

        rules: [

        {

        test: /\.css$/,

        use: [

        MiniCssExtractPlugin.loader,

        'css-loader'

        ],

        },

        {

        test: /\.vue$/,

        loader: [

        'vue-loader',

        ],

        },

        {

        test: /\.js$/,

        use: {

        loader: 'babel-loader',

        options: {

        presets: ['env']

        }

        },

        exclude: /node_modules/

        },

        {

        test: /\.(png|jpg|gif|svg)$/,

        loader: 'file-loader',

        options: {

        name: '[name].[ext]?[hash]'

        }

        }

        ]

        },

        resolve: {

        extensions: ['*', '.js', '.vue', '.json']

        },

        plugins: [

        new webpack.DefinePlugin({

        'process.env.isMiniprogram': true, // 注入環(huán)境變量,用于業(yè)務(wù)代碼判斷

        }),

        new MiniCssExtractPlugin({

        filename: '[name].wxss',

        }),

        new VueLoaderPlugin(),

        new MpPlugin(require('./miniprogram.config.js')),

        ],

        }

        2.7 創(chuàng)建 main.mp.js

        在 05-rem/src 下創(chuàng)建 main.mp.js 文件,內(nèi)容如下:

        import Vue from 'vue'

        import App from './App'

        export default function createApp() {

        const container = document.createElement('div')

        container.id = 'app'

        document.body.appendChild(container)

        window.onload = function() {

        if (process.env.isMiniprogram) {

        // 小程序

        document.documentElement.style.fontSize = wx.getSystemInfoSync().screenWidth / 16 + 'px'

        } else {

        // Web 端

        document.documentElement.style.fontSize = document.documentElement.getBoundingClientRect().width / 16 + 'px'

        }

        }

        return new Vue({

        el: '#app',

        render: h => h(App)

        })

        }

        2.8 小程序端效果預(yù)覽

        npm run mp

      圖片4

      tags:
      聲明:本站稿件版權(quán)均屬千鋒教育所有,未經(jīng)許可不得擅自轉(zhuǎn)載。
      10年以上業(yè)內(nèi)強(qiáng)師集結(jié),手把手帶你蛻變精英
      請您保持通訊暢通,專屬學(xué)習(xí)老師24小時內(nèi)將與您1V1溝通
      免費(fèi)領(lǐng)取
      今日已有369人領(lǐng)取成功
      劉同學(xué) 138****2860 剛剛成功領(lǐng)取
      王同學(xué) 131****2015 剛剛成功領(lǐng)取
      張同學(xué) 133****4652 剛剛成功領(lǐng)取
      李同學(xué) 135****8607 剛剛成功領(lǐng)取
      楊同學(xué) 132****5667 剛剛成功領(lǐng)取
      岳同學(xué) 134****6652 剛剛成功領(lǐng)取
      梁同學(xué) 157****2950 剛剛成功領(lǐng)取
      劉同學(xué) 189****1015 剛剛成功領(lǐng)取
      張同學(xué) 155****4678 剛剛成功領(lǐng)取
      鄒同學(xué) 139****2907 剛剛成功領(lǐng)取
      董同學(xué) 138****2867 剛剛成功領(lǐng)取
      周同學(xué) 136****3602 剛剛成功領(lǐng)取
      相關(guān)推薦HOT
      抖店入駐收費(fèi)多少?開抖店費(fèi)用是多少?

      如果要開通抖音小店,需要先把抖音賬號開通商品櫥窗功能。入駐之后,可以選擇頭條賬號、抖音賬號、火山賬號任一類型注冊或登錄。那開個抖店要多...詳情>>

      2023-09-19 07:50:26
      想做直播帶貨的貨源哪里來?怎么找貨源?

      現(xiàn)如今直播推廣的方式是非?;鸬?,有著非常多的賣家都是利用直播推廣店鋪產(chǎn)品,效果也是非常不錯。但很多賣家想要了解現(xiàn)在直播帶貨的話什么產(chǎn)品...詳情>>

      2023-09-19 07:47:16
      適合三農(nóng)領(lǐng)域的名字?有何技巧?

      現(xiàn)在在抖音上很多博主會選擇直播來賺取更多的流量以及利潤,直播間的東西也有很多讓消費(fèi)者信任并且喜歡的,而且隨著越來越多人直播,很多農(nóng)產(chǎn)品...詳情>>

      2023-09-19 07:06:05
      抖店商品發(fā)布違規(guī)怎么申訴?有何規(guī)則?

      抖店服務(wù)市場服務(wù)商發(fā)布違禁信息如何處理?情節(jié)嚴(yán)重程度判定原則:違規(guī)嚴(yán)重等級主要通過服務(wù)商違規(guī)次數(shù)、造成后果的嚴(yán)重程度、獲利或?qū)е聯(lián)p失的...詳情>>

      2023-09-19 06:59:55
      “泛垂直起號”可能是2023年最高效的起號方式

      這可能是明年最好用的旗號方式了,今天教大家一個很野,但是可以讓你三天漲1000粉的偏方。去年前年啊,每個人都教你,誰知七號對著自己的產(chǎn)品拍...詳情>>

      2023-09-19 06:37:38
      開班信息
      北京校區(qū)
      • 北京校區(qū)
      • 大連校區(qū)
      • 廣州校區(qū)
      • 成都校區(qū)
      • 杭州校區(qū)
      • 長沙校區(qū)
      • 合肥校區(qū)
      • 南京校區(qū)
      • 上海校區(qū)
      • 深圳校區(qū)
      • 武漢校區(qū)
      • 鄭州校區(qū)
      • 西安校區(qū)
      • 青島校區(qū)
      • 重慶校區(qū)
      • 太原校區(qū)
      • 沈陽校區(qū)
      • 南昌校區(qū)
      • 哈爾濱校區(qū)