欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue2.0項(xiàng)目集成Cesium的實(shí)現(xiàn)方法

 更新時(shí)間:2019年07月30日 11:07:03   作者:林珞  
這篇文章主要介紹了vue2.0項(xiàng)目集成Cesium的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

安裝cesium

在已有項(xiàng)目中執(zhí)行,

npm i cesium

修改配置

build/webpack.base.conf.js

1、定義 Cesium 源碼路徑

const cesiumSource = '../node_modules/cesium/Source'

'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
//--cesium--配置
const cesiumSource = '../node_modules/cesium/Source'; 

2、在output 里加入sourcePrefix: ' ' 讓webpack 正確處理多行字符串

3、配置 amd參數(shù)

4、module中在rules后添加 unknownContextCritical: false,

module.exports = {
  context: path.resolve(__dirname, '../'),
  entry: {
    app: ["babel-polyfill", './src/main.js']
  },
  output: {
    path: config.build.assetsRoot,
    filename: '[name].js',
    publicPath: process.env.NODE_ENV === 'production' ?
      config.build.assetsPublicPath : config.dev.assetsPublicPath,
    //--cesium--配置------------------------------------
    sourcePrefix: ' '
  },
  //--cesium--配置----------------------------------------
  amd:{
    toUrlUndefined: true
  },
  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      '@': resolve('src'),
      //--cesium--配置
      'cesium': path.resolve(__dirname, cesiumSource)
    }
  },
  module: {
    rules: [
    ...
    ],
    //--cesium--配置-------------------------------------
    //unknownContextRegExp: /^.\/.*$/
    unknownContextCritical: false,
  }
}

build/webpack.dev.conf.js

1、定義 Cesium 源碼路徑和Cesium Workers 路徑

const cesiumSource = 'node_modules/cesium/Source'
const cesiumWorkers = '../Build/Cesium/Workers' 

(注意這里的 node_modules 與webpack.base.conf.js的不同,前面沒有../)

2、定義CESIUM_BASE_URL變量

3、在plugins 中加入下面插件,拷貝靜態(tài)資源

plugins: [
  new webpack.DefinePlugin({
   'process.env': require('../config/dev.env'),
   //--cesium--配置-------------------------------------------
   'CESIUM_BASE_URL': JSON.stringify('') 
  }),
  new webpack.HotModuleReplacementPlugin(),
  new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
  new webpack.NoEmitOnErrorsPlugin(),
  // https://github.com/ampedandwired/html-webpack-plugin
  new HtmlWebpackPlugin({
   filename: 'index.html',
   template: 'index.html',
   inject: true
  }),
  //--cesium--配置---------------------------------------------
  new CopyWebpackPlugin([ { from: path.join(cesiumSource, cesiumWorkers), to: 'Workers' } ]),   //flag
  new CopyWebpackPlugin([ { from: path.join(cesiumSource, 'Assets'), to: 'Assets' } ]),
  new CopyWebpackPlugin([ { from: path.join(cesiumSource, 'Widgets'), to: 'Widgets' } ]),
  new CopyWebpackPlugin([ { from: path.join(cesiumSource, 'ThirdParty/Workers'), to: 'ThirdParty/Workers' } ]),
  new CopyWebpackPlugin([ { from: 'ThirdParty', to: 'ThirdParty' } ]),

  // copy custom static assets
  new CopyWebpackPlugin([
   {
    from: path.resolve(__dirname, '../static'),
    to: config.dev.assetsSubDirectory,
    ignore: ['.*']
   }
  ])
 ]

build/webpack.prod.conf.js

1、定義

 const cesiumSource = 'node_modules/cesium/Source';
 const cesiumWorkers = '../Build/Cesium/Workers';

2、定義'CESIUM_BASE_URL'變量

3、在plugins 中加入下面插件,拷貝靜態(tài)資源

plugins: [
  // http://vuejs.github.io/vue-loader/en/workflow/production.html
  new webpack.DefinePlugin({
   'process.env': env,
   //--cesium--配置--------------------------------------
   'CESIUM_BASE_URL': JSON.stringify('static')
  }),
  ...
  new HtmlWebpackPlugin({
    ...
  },
  //--cesium--配置--------------------------------------
  new CopyWebpackPlugin([ { from: path.join(cesiumSource, cesiumWorkers), to: 'static/Workers' } ]),//flag
  new CopyWebpackPlugin([ { from: path.join(cesiumSource, 'Assets'), to: 'static/Assets' } ]),
  new CopyWebpackPlugin([ { from: path.join(cesiumSource, 'Widgets'), to: 'static/Widgets' } ]),
  new CopyWebpackPlugin([ { from: path.join(cesiumSource, 'ThirdParty/Workers'), to: 'ThirdParty/Workers' } ]),
  new CopyWebpackPlugin([ { from: 'ThirdParty', to: 'ThirdParty' } ]),
  ...

ThirdParty

在項(xiàng)目根目錄新建文件夾ThirdParty,放入draco_decoder.wasm文件,在加載gltf模型文件需要用到

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vuejs第十二篇之動(dòng)態(tài)組件全面解析

    Vuejs第十二篇之動(dòng)態(tài)組件全面解析

    組件(Component)是 Vue.js 最強(qiáng)大的功能之一。組件可以擴(kuò)展 HTML 元素,封裝可重用的代碼。接下來通過本文給大家介紹Vuejs第十二篇之動(dòng)態(tài)組件,非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友一起看看吧
    2016-09-09
  • Vue路由跳轉(zhuǎn)問題記錄詳解

    Vue路由跳轉(zhuǎn)問題記錄詳解

    本篇文章主要介紹了Vue路由跳轉(zhuǎn)問題記錄詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-06-06
  • 基于vue3.0.1beta搭建仿京東的電商H5項(xiàng)目

    基于vue3.0.1beta搭建仿京東的電商H5項(xiàng)目

    這篇文章主要介紹了基于vue3.0.1beta搭建仿京東的電商H5項(xiàng)目,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-05-05
  • Vue中v-for更新檢測(cè)的操作方法

    Vue中v-for更新檢測(cè)的操作方法

    v-for 指令需要使用 item in items 形式的特殊語法,其中 items 是源數(shù)據(jù)數(shù)組,而 item 則是被迭代的數(shù)組元素的別名。今天通過本文給大家介紹Vue中v-for更新檢測(cè)的操作方法,感興趣的朋友一起看看吧
    2021-10-10
  • Vue Echarts實(shí)現(xiàn)柱形圖從右向左滾動(dòng)效果

    Vue Echarts實(shí)現(xiàn)柱形圖從右向左滾動(dòng)效果

    這篇文章主要為大家詳細(xì)介紹了Vue如何利用Echarts實(shí)現(xiàn)柱形圖從右向左滾動(dòng)的效果,文中的示例代碼簡(jiǎn)潔易懂,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-05-05
  • 解決vue動(dòng)態(tài)下拉菜單 有數(shù)據(jù)未反應(yīng)的問題

    解決vue動(dòng)態(tài)下拉菜單 有數(shù)據(jù)未反應(yīng)的問題

    這篇文章主要介紹了解決vue動(dòng)態(tài)下拉菜單 有數(shù)據(jù)未反應(yīng)的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-08-08
  • vue側(cè)邊欄動(dòng)態(tài)生成下級(jí)菜單的方法

    vue側(cè)邊欄動(dòng)態(tài)生成下級(jí)菜單的方法

    今天小編就為大家分享一篇vue側(cè)邊欄動(dòng)態(tài)生成下級(jí)菜單的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • 在Vue使用$attrs實(shí)現(xiàn)構(gòu)建高級(jí)組件

    在Vue使用$attrs實(shí)現(xiàn)構(gòu)建高級(jí)組件

    本文我們主要來看下Vue3中的$attrs屬性。首先,我們會(huì)介紹它的用途以及它的實(shí)現(xiàn)與Vue2有哪些不兩同點(diǎn),并通過事例來加深對(duì)它的理解
    2022-09-09
  • vue 實(shí)現(xiàn)復(fù)制內(nèi)容到粘貼板clipboard的方法

    vue 實(shí)現(xiàn)復(fù)制內(nèi)容到粘貼板clipboard的方法

    下面小編就為大家分享一篇vue 實(shí)現(xiàn)復(fù)制內(nèi)容到粘貼板clipboard的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • vue在項(xiàng)目中實(shí)現(xiàn)base64加密解密的示例代碼

    vue在項(xiàng)目中實(shí)現(xiàn)base64加密解密的示例代碼

    這篇文章主要為大家詳細(xì)介紹了vue在項(xiàng)目中實(shí)現(xiàn)base64加密解密的兩種方法,文中的示例代碼講解詳細(xì),具有一定的參考價(jià)值,有需要的小伙伴可以了解一下
    2023-10-10

最新評(píng)論