Vue-cli开发多页面应用

Vue3 多页面开发详解,详细配置、场景、问题及解决方案 在 Vue3 中,虽然默认推荐单页面应用(SPA),但多页面应用(MPA)在一些场景下更合适。 阅读详情

写在前面,Vue多页面应用场景:
1.项目很老了后端不愿意改接口和配置,前端想尝试新技术。
2.多页面可能更多是考虑首屏加载速度,或者SEO等情况,主流方案如SSR。当然这种单页面也有对应解决方案 点击查看

回归正题

思路:单页面改成多页面不就两个东西吗!entry ouput ,其中entry可以写死也可以循环遍历,output主要是在htmlplugin中体现也可以写死或者便利,我主要说下遍历这种情况。写死的请看这里

多页面应用其实只需要修改vue-cli中的几个文件的配置就可以了

  • utils.js
  • webpack.base.conf.js
  • webpack.dev.conf.js
  • webpack.prod.conf.js

目录结构

├── README.md
├── build
│ ├── build.js
│ ├── check-versions.js
│ ├── dev-client.js
│ ├── dev-server.js
│ ├── utils.js
│ ├── vue-loader.conf.js
│ ├── webpack.base.conf.js
│ ├── webpack.dev.conf.js
│ └── webpack.prod.conf.js
├── config
│ ├── dev.env.js
│ ├── index.js
│ └── prod.env.js
├── package.json
├── src
│ ├── minxins
│ ├── assets
│ │ └── logo.png
│ ├── components
│ │ ├── Hello.vue
│ │ └── cell.vue
│ └── pages
│ │ ├── pc
│ │ │ ├── pindex.html
│ │ │ ├── pindex.js
│ │ │ └── pindex.vue
│ │ └── mobile
│ │ ├── mindex.html
│ │ ├── mindex.js
│ │ ├── mindex.vue
│ ├── utils
└── static

添加依赖

cnpm i glob -D

修改utils.js

'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const packageConfig = require('../package.json')

exports.assetsPath = function (_path) {
  const assetsSubDirectory = process.env.NODE_ENV === 'production'
    ? config.build.assetsSubDirectory
    : config.dev.assetsSubDirectory

  return path.posix.join(assetsSubDirectory, _path)
}

exports.cssLoaders = function (options) {
  options = options || {}

  const cssLoader = {
    loader: 'css-loader',
    options: {
      sourceMap: options.sourceMap
    }
  }

  const postcssLoader = {
    loader: 'postcss-loader',
    options: {
      sourceMap: options.sourceMap
    }
  }

  // generate loader string to be used with extract text plugin
  function generateLoaders (loader, loaderOptions) {
    const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]

    if (loader) {
      loaders.push({
        loader: loader + '-loader',
        options: Object.assign({}, loaderOptions, {
          sourceMap: options.sourceMap
        })
      })
    }

    // Extract CSS when that option is specified
    // (which is the case during production build)
    if (options.extract) {
      return ExtractTextPlugin.extract({
        use: loaders,
        fallback: 'vue-style-loader'
      })
    } else {
      return ['vue-style-loader'].concat(loaders)
    }
  }

  // https://vue-loader.vuejs.org/en/configurations/extract-css.html
  return {
    css: generateLoaders(),
    postcss: generateLoaders(),
    less: generateLoaders('less'),
    sass: generateLoaders('sass', { indentedSyntax: true }),
    scss: generateLoaders('sass'),
    stylus: generateLoaders('stylus'),
    styl: generateLoaders('stylus')
  }
}

// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
  const output = []
  const loaders = exports.cssLoaders(options)

  for (const extension in loaders) {
    const loader = loaders[extension]
    output.push({
      test: new RegExp('\\.' + extension + '$'),
      use: loader
    })
  }

  return output
}

exports.createNotifierCallback = () => {
  const notifier = require('node-notifier')

  return (severity, errors) => {
    if (severity !== 'error') return

    const error = errors[0]
    const filename = error.file && error.file.split('!').pop()

    notifier.notify({
      title: packageConfig.name,
      message: severity + ': ' + error.name,
      subtitle: filename || '',
      icon: path.join(__dirname, 'logo.png')
    })
  }
}

/* 这里是添加的部分 ---------------------------- 开始 */

// glob是webpack安装时依赖的一个第三方模块,还模块允许你使用 *等符号, 例如lib/*.js就是获取lib文件夹下的所有js后缀名的文件
var glob = require('glob')
// 页面模板
var HtmlWebpackPlugin = require('html-webpack-plugin')
// 取得相应的页面路径,因为之前的配置,所以是src文件夹下的pages文件夹
var PAGE_PATH = path.resolve(__dirname, '../src')
// 用于做相应的merge处理
var merge = require('webpack-merge')


//多入口配置
// 通过glob模块读取pages文件夹下的所有对应文件夹下的js后缀文件,如果该文件存在
// 那么就作为入口处理

exports.entries = function () {
    var entryFiles = glob.sync(PAGE_PATH + '/+(mobile|pc)/components/pages/*.js')
    var map = {}
    entryFiles.forEach((filePath) => {
        var filename = filePath.substring(filePath.lastIndexOf('\/') + 1, filePath.lastIndexOf('.'))
        map[filename] = filePath
    })
    return map
}

//多页面输出配置
// 与上面的多页面入口配置相同,读取pages文件夹下的对应的html后缀文件,然后放入数组中
exports.htmlPlugin = function () {
    let entryHtml = glob.sync(PAGE_PATH + '/+(mobile|pc)/components/pages/*.html')
    let arr = []
    entryHtml.forEach((filePath) => {
        let filename = filePath.substring(filePath.lastIndexOf('\/') + 1, filePath.lastIndexOf('.'))
        let conf = {
            // 模板来源
            template: filePath,
            // 文件名称
            filename: filename + '.html',
            // 页面模板需要加对应的js脚本,如果不加这行则每个页面都会引入所有的js脚本
            chunks: ['manifest', 'vendor', filename],
            inject: true
        }
        if (process.env.NODE_ENV === 'production') {
            conf = merge(conf, {
                minify: {
                    removeComments: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true
                },
                chunksSortMode: 'dependency'
            })
        }
        arr.push(new HtmlWebpackPlugin(conf))
    })
    return arr
}
/* 这里是添加的部分 ---------------------------- 结束 */

修改webpack.base.conf.js

'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
  return path.join(__dirname, '..', dir)
}

const createLintingRule = () => ({
  test: /\.(js|vue)$/,
  loader: 'eslint-loader',
  enforce: 'pre',
  include: [resolve('src'), resolve('test')],
  options: {
    formatter: require('eslint-friendly-formatter'),
    emitWarning: !config.dev.showEslintErrorsInOverlay
  }
})

const webpackConfig = {
  context: path.resolve(__dirname, '../'),
   /* 修改部分 ---------------- 开始 */
  entry: utils.entries(),
  /* 修改部分 ---------------- 结束 */
  output: {
    path: config.build.assetsRoot,
    filename: '[name].js',
    publicPath: process.env.NODE_ENV === 'production'
      ? config.build.assetsPublicPath
      : config.dev.assetsPublicPath
  },
  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      '@': resolve('src'),
    }
  },
  module: {
    rules: [
      ...(config.dev.useEslint ? [createLintingRule()] : []),
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('img/[name].[hash:7].[ext]')
        }
      },
      {
        test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('media/[name].[hash:7].[ext]')
        }
      },
      {
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
        }
      }
    ]
  },
  node: {
    // prevent webpack from injecting useless setImmediate polyfill because Vue
    // source contains it (although only uses it if it's native).
    setImmediate: false,
    // prevent webpack from injecting mocks to Node native modules
    // that does not make sense for the client
    dgram: 'empty',
    fs: 'empty',
    net: 'empty',
    tls: 'empty',
    child_process: 'empty'
  }
} // 原来的 module.exports 代码赋值给变量 webpackConfig

修改webpack.dev.conf.js

'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')

const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)

const devWebpackConfig = merge(baseWebpackConfig, {
  module: {
    rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
  },
  // cheap-module-eval-source-map is faster for development
  devtool: config.dev.devtool,

  // these devServer options should be customized in /config/index.js
  devServer: {
    clientLogLevel: 'warning',
    historyApiFallback: {
      rewrites: [
        { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
      ],
    },
    hot: true,
    contentBase: false, // since we use CopyWebpackPlugin.
    compress: true,
    host: HOST || config.dev.host,
    port: PORT || config.dev.port,
    open: config.dev.autoOpenBrowser,
    overlay: config.dev.errorOverlay
      ? { warnings: false, errors: true }
      : false,
    publicPath: config.dev.assetsPublicPath,
    proxy: config.dev.proxyTable,
    quiet: true, // necessary for FriendlyErrorsPlugin
    watchOptions: {
      poll: config.dev.poll,
    },
    disableHostCheck: true
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': require('../config/dev.env')
    }),
    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
    // }),
    /* 注释这个区域的文件 ------------- 结束 */
    // copy custom static assets
    new CopyWebpackPlugin([
      {
        from: path.resolve(__dirname, '../static'),
        to: config.dev.assetsSubDirectory,
        ignore: ['.*']
      }
    ])
 /* 添加 .concat(utils.htmlPlugin()) ----------*/
  ].concat(utils.htmlPlugin())
})

module.exports = new Promise((resolve, reject) => {
  portfinder.basePort = process.env.PORT || config.dev.port
  portfinder.getPort((err, port) => {
    if (err) {
      reject(err)
    } else {
      // publish the new Port, necessary for e2e tests
      process.env.PORT = port
      // add port to devServer config
      devWebpackConfig.devServer.port = port

      // Add FriendlyErrorsPlugin
      devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
        compilationSuccessInfo: {
          messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
        },
        onErrors: config.dev.notifyOnErrors
        ? utils.createNotifierCallback()
        : undefined
      }))

      resolve(devWebpackConfig)
    }
  })
})

修改webpack.prod.conf.js

'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

const env = process.env.NODE_ENV === 'testing'
  ? require('../config/test.env')
  : require('../config/prod.env')

const webpackConfig = merge(baseWebpackConfig, {
  module: {
    rules: utils.styleLoaders({
      sourceMap: config.build.productionSourceMap,
      extract: true,
      usePostCSS: true
    })
  },
  devtool: config.build.productionSourceMap ? config.build.devtool : false,
  output: {
    path: config.build.assetsRoot,
    filename: utils.assetsPath('js/[name].[chunkhash].js'),
    chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
  },
  plugins: [
    // http://vuejs.github.io/vue-loader/en/workflow/production.html
    new webpack.DefinePlugin({
      'process.env': env
    }),
    new UglifyJsPlugin({
      uglifyOptions: {
        compress: {
          warnings: false
        }
      },
      sourceMap: config.build.productionSourceMap,
      parallel: true
    }),
    // extract css into its own file
    new ExtractTextPlugin({
      filename: utils.assetsPath('css/[name].[contenthash].css'),
      // Setting the following option to `false` will not extract CSS from codesplit chunks.
      // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
      // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, 
      // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
      allChunks: true,
    }),
    // Compress extracted CSS. We are using this plugin so that possible
    // duplicated CSS from different components can be deduped.
    new OptimizeCSSPlugin({
      cssProcessorOptions: config.build.productionSourceMap
        ? { safe: true, map: { inline: false } }
        : { safe: true }
    }),
    // generate dist index.html with correct asset hash for caching.
    // you can customize output by editing /index.html
    // see https://github.com/ampedandwired/html-webpack-plugin
   /* 注释这个区域的内容 ---------------------- 开始 */
    // new HtmlWebpackPlugin({
    //   filename: config.build.index,
    //   template: 'index.html',
    //   inject: true,
    //   minify: {
    //     removeComments: true,
    //     collapseWhitespace: true,
    //     removeAttributeQuotes: true
    //     // more options:
    //     // https://github.com/kangax/html-minifier#options-quick-reference
    //   },
    //   // necessary to consistently work with multiple chunks via CommonsChunkPlugin
    //   chunksSortMode: 'dependency'
    // }),
    /* 注释这个区域的内容 ---------------------- 结束 */
    //   // necessary to consistently work with multiple chunks via CommonsChunkPlugin
    //   chunksSortMode: 'dependency'
    // }),
    // keep module.id stable when vendor modules does not change
    new webpack.HashedModuleIdsPlugin(),
    // enable scope hoisting
    new webpack.optimize.ModuleConcatenationPlugin(),
    // split vendor js into its own file
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks (module) {
        // any required modules inside node_modules are extracted to vendor
        return (
          module.resource &&
          /\.js$/.test(module.resource) &&
          module.resource.indexOf(
            path.join(__dirname, '../node_modules')
          ) === 0
        )
      }
    }),
    // extract webpack runtime and module manifest to its own file in order to
    // prevent vendor hash from being updated whenever app bundle is updated
    new webpack.optimize.CommonsChunkPlugin({
      name: 'manifest',
      minChunks: Infinity
    }),
    // This instance extracts shared chunks from code splitted chunks and bundles them
    // in a separate chunk, similar to the vendor chunk
    // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
    new webpack.optimize.CommonsChunkPlugin({
      name: 'app',
      async: 'vendor-async',
      children: true,
      minChunks: 3
    }),

    // copy custom static assets
    new CopyWebpackPlugin([
      {
        from: path.resolve(__dirname, '../static'),
        to: config.build.assetsSubDirectory,
        ignore: ['.*']
      }
    ])
      /* 该位置添加 .concat(utils.htmlPlugin()) ------------------- */
  ].concat(utils.htmlPlugin())
})

if (config.build.productionGzip) {
  const CompressionWebpackPlugin = require('compression-webpack-plugin')

  webpackConfig.plugins.push(
    new CompressionWebpackPlugin({
      asset: '[path].gz[query]',
      algorithm: 'gzip',
      test: new RegExp(
        '\\.(' +
        config.build.productionGzipExtensions.join('|') +
        ')$'
      ),
      threshold: 10240,
      minRatio: 0.8
    })
  )
}

if (config.build.bundleAnalyzerReport) {
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
  webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}

module.exports = webpackConfig

修改congig/index.js

build: {
    env: require('./prod.env'),
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    /*修改开始*/
    assetsPublicPath: './',
    /*修改结束*/
    productionSourceMap: true,
    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],
    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  },

这个修改是解决查看index.html文件之后会发现资源的引用路径是:

/dist/js………

这样,如果你的dist文件不是在根目录下的,就根本找不到资源。

参考

https://segmentfault.com/a/1190000011265006

vue 多页面应用例子_vue-cli + webpack 多页面实例应用 关于vue.jsvue.js是一套构建用户界面的 轻型的渐进式前端框架。它的目标是通过尽可能简单的 API 实现响应的数据绑定和组合的视图组件。使用vue可以给你的开发带来极致的编程体验。关于vue-cliVue-cli是vue官方提供的一个命令行工具(vue-cli),可用于快速搭建大型单页应用。该工具提供开箱即用的构建工具配置,带来现代化的前端开发流程。只需一分钟即可启动带热重载、保存时静态检... 阅读详情

相关推荐

Vue 项目构建与开发入门:多页路由与模板解析

在模板渲染中,我们只能够使用 htmlWebpackPlugin 内部的一些属性和方法来进行模板的定制化开发,那么如果遇到需要根据不同环境来引入不同资源,同时不同模板间的配置还可能不一样的需求情况的话,我们使用自定义配置会比较方便。比如我们需要在生产环境模板中引入第三方统计脚本:...return `return ''}),...然后在页面模板中通过获取自定义配置对象并进行输出:同时为 addScript 方法添加参数 from:return `

YOLO 576

vue多页实践-开发

获取到的对象 可以在 进行打印 在 中的 对象写入多页配置(也就是比单页多了一个 pages 配置) 运行-打包 上述配置运行 会运行所有应用 +掘金小册 Vue 项目构建与开发入门

mucuni的博客 2795

构建Vue多页面应用项目的源码解析

Vue.js 是一个轻量级的JavaScript框架,专为构建用户界面而设计。它以数据驱动和组件化的思想为基础,易于上手,同时也具备了扩展和集成其他库的能力。Vue的核心库只关注视图层,使得它能够轻松地与现有项目中的其他库或既有后端技术结合。通过声明式的数据绑定和组件系统,Vue能够帮助开发者快速构建出交互式的单页面应用(SPA)。多页面应用(MPA, Multi-Page Application)是指一个网站中包含多个独立的页面,每个页面都有自己独立的HTML文件。

weixin_35238815的博客 818

实战 Vue 之配置多页面应用

最近一直在做企业钉钉应用开发,即每个功能模块都是一个单独的应用,单独的页面,配置到钉钉里面,就可以单独访问了。比如开发登陆模块的时候,会搭建一套环境,创建 login.html 以及相应的 js 和 css。再开发注册模块的时候,又搭建一套环境,创建 register.html 以及相应的 js 和 css。

杏子 2万+

基于VueCLI3的多页应用开发实战演示

Vue CLI 3 是 Vue 官方推出的现代化前端开发工具,基于 Webpack 4 构建,提供了开箱即用的项目初始化体验。相比 Vue CLI 2,其去除了繁琐的build和config目录,将配置抽象为,提升了可维护性与扩展性。核心优势包括:开箱即用:内置 Babel、TypeScript、ESLint、PostCSS 等常用工具,无需手动配置。Vue UI 图形化界面:通过vue ui命令即可可视化管理项目、插件与构建配置。插件系统架构。

weixin_35749796的博客 949

记录——影刀RPA高级操作题(二)——使用影刀RPA内置包和”Xpath“获取数据,获取数据写入目标MySQL

【代码】记录——影刀RPA高级操作题(二)——使用影刀RPA内置包和”Xpath“获取数据,获取数据写入目标MySQL。

m0_74824002的博客 842

vue如何实现多页面应用网页

为每个页面创建一个 Vue 实例,这样每个页面都可以拥有自己独立的 Vue 实例,它们之间不会相互影响。总之,使用 Vue 实现多页面应用的关键是要将每个页面视为一个独立的实例,并且使用路由管理页面之间的导航。你可以使用不同的路由来实现每个页面的页面切换和导航。总的来说,实现多页面应用的核心是配置多个入口文件,为每个页面指定唯一的容器元素,以及在 HTML 模板文件中引入对应的 bundle 文件。如果你需要在多个页面上使用相同的组件和逻辑,可以将它们提取到单独的文件中,并在多个页面中导入它们。

JackieDYH的博客 4000

MTK-AWB 小结 (二)

调试总结:可以将offset 对应的ratio加大,保留更多的喜好色(偏色),影响WF statistic gain,从而影响最终的awb gain。这一部分前期CCT校准的时候就会算出一组默认值,当然这个offset offse 值用于优化T,S,wf 光下的偏色喜好度. offset。后面遇到 A H Shad 光收白或者偏色,还可以优化 A 的offset ,H offset,shad offset.new offset 计算过程(Day locus offset 和M/G offset )

qq_46056347的博客 1168

使用vue-cli3多页面开发apicloud应用

apicloud的开发方式太古老了,官方出的那个cli也不咋地,分享一下基于vue-cli3开发apicloud的方式。 因为apicloud里面有window和frame的概念,所以肯定是多页面才能发挥出apicloud的优势。 不熟悉vue-cli3的,建议先看下文档 创建项目 vue create vue-for-apicloud 复制代码然后选择 Manually select featu...

weixin_33885676的博客 995

手把手教你用MATLAB和PSIM搞定Buck电路控制器:从传递函数到运放电路实战

本文详细介绍了如何使用MATLAB和PSIM协同设计Buck电路控制器,从传递函数推导到运放电路实现的完整流程。通过小信号建模、波特图分析和双平台仿真验证,帮助电力电子工程师解决理论到实践的转化难题,提升Buck电路控制器设计的效率和可靠性。

weixin_29271053的博客 269

Windows 11下Telnet端口23连接失败的终极解决方案(附详细排查步骤)

本文详细解析了Windows 11系统中Telnet端口23连接失败的常见原因及解决方案。从Telnet客户端功能启用、服务端配置检查到网络连接诊断,提供了一套完整的排查步骤,帮助用户快速定位并解决连接问题,同时给出了安全使用Telnet的建议。

win55的博客 456

vue cli 2.9.6多页面应用开发

vue cli 2.9.6多页面应用开发 vue cli脚手架默认是单应用页面开发,有时候遇到项目需要一个项目放入两个入口,这样的话就需要用到多页面了。这样需要我们手动去修改目录,下面是采用一个案例: (注意 : 以vue2.9.6为例,vue3以上就没有build、config等目录) 1.安装vue cli脚手架(这里不做介绍,可以直接百度); 链接:https://www.cnblogs.com/dudu123/p/10405345.html 2.安装完成,你的目录应该是这样的。 你的src目录应该

weixin_45172119的博客 541

域控制器迁移后NETLOGON共享丢失的修复指南

本文详细解析了在Windows域控制器迁移后NETLOGON共享丢失的故障现象与修复方法。通过使用Dcdiag工具诊断,定位注册表键值SysVolReady异常及SCRIPTS目录缺失等核心原因,并提供了修改注册表、创建目录、重启Netlogon服务等逐步修复指南,帮助管理员快速恢复域用户登录功能,确保业务连续性。

weixin_29245767的博客 88

使用Vue CLI3开发多页面应用

一、安装vue-cli3 1、如果你已经全局安装了旧版本的vue-cli(1.x 或 2.x),你需要先通过npm uninstall vue-cli -g或yarn global remove vue-cli卸载它。 2、安装命令:npm install -g @vue/cli 或yarn global add @vue/cli 3、通过vue --version这个命令来检查...

weixin_30670925的博客 1010

从FedAvg到实战:手把手教你用PyTorch复现联邦学习经典论文实验(MNIST/CIFAR-10)

本文详细介绍了如何使用PyTorch复现联邦学习经典算法FedAvg在MNIST和CIFAR-10数据集上的实验。从环境搭建、数据非IID划分到模型实现和参数聚合,手把手教你掌握联邦学习的核心技术与实战技巧,帮助开发者和研究人员快速实现隐私保护的分布式机器学习方案。

weixin_29053695的博客 253

告别C盘空间焦虑!Miniforge环境路径精准配置全攻略

本文深入解析Miniforge虚拟环境默认占用C盘空间的根本原因,即未正确配置`.condarc`文件中的`envs_dirs`路径优先级。通过详细的诊断步骤与配置命令,指导用户将环境路径精准迁移至指定磁盘(如D盘),并分享禁用自动激活、使用`--prefix`参数等高阶技巧,帮助开发者彻底告别C盘空间焦虑,实现虚拟环境的整洁与可控管理。

weixin_28831399的博客 238

基于vue-cli3多页面开发apicloud应用

之前开发项APP项目直接用APICloud+原生js的方式进行编写,整个项目下来发现开发慢,页面代码多且复杂,维护起来相对困难,而且文件大打包之后的APP会比较大,apicloud的框架也不好用,支持部分es67(像let、const、import等es6新特性不支持写的太难受了) 采用vue-cli+APIcloud的方式写解决以上痛点,开发灵活,并且打包之后体积更小速度更快 环境依赖 vue...

weixin_33720956的博客 681

6、基于深度强化学习的无人机路径规划

本文介绍了一种结合人工势场法的改进DQN深度强化学习算法在无人机路径规划中的应用。通过设计合理的网络结构、状态空间、动作空间和融合引力-斥力机制的奖励函数,实现了无人机在复杂环境中的自主避障与目标导向飞行。采用轻量级神经网络提升实时性,并在Gazebo仿真环境中进行训练与测试,结果表明该算法具有快速收敛、高成功率和良好适应性。实验评估指标包括损失函数、最大Q值和任务成功率,验证了方法的有效性。文章还探讨了其在物流配送、农业植保和环境监测等领域的应用前景,并展望了多无人机协同与复杂环境适应性等未来研究方向。

html8的博客 241

vue.js之使用Vue CLI3开发多页面应用

1、安装:npm install -g @vue/cli 2、创建项目,public相当于原来的static,里面的index.html是项目的入口 ,src同以前一样。 注意的是,cli3.0没有build和config了, 想要配置的话,需要在项目根目录下创建vue.config.js文件 3、在vue.config.js中配置如下 module.exports = { pages: ...

菜鸟karroy 764

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Vue.js Cli 3.0 多页面开发案例解析

本文梗概 Vue 是很好用,但是以往的都是单页面应用,这就导致了一些传统的项目移植困难,一些用了 JQ 的插件的等等写法都要改变。也还用专门找到相对于的 Vue 的插件才行,这次的 Cli 3.0 可以在原来项目的基础上直接移植,非常方便。 在本文中,会讲到如下内容: Vue 多页面的优势与劣势 Cli 3.0 的基本配置 Cli 3.0 多页面的打包上线 Cli 3.0 的目录解析 如何提升构建效率 受众人群:经常用 Vue 单页面开发的人员,对多页面有兴趣,且实际工作中有需求。老项目想前后端分离,考虑效

lllomh的博客 2741

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Vue CLI3 多页应用构建工具:强大的前端开发新选择

Vue CLI3 多页应用构建工具:强大的前端开发新选择 项目简介 Vue CLI3 是一个由 Vue.js 团队官方维护的脚手架工具,用于快速搭建高质量的 Vue.js 应用程序。而 则是基于 Vue CLI3 的扩展,它专为构建多页面应用程序(Multi-Page Application, MPAs)设计,使得在同一个项目中管理多个独立的入口页面变得更加轻松和高效。 技术分析 1. Vue ...

gitblog_00058的博客 531

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

vue-cli多页面应用实践,实现组件预览

vue-cli 多页面应用 vue技术栈的同学,大多是用vue-cli来搭建单页面应用。如后台管理系统,H5活动等; vue-cli多页面应用开发 在初学时可能你有浏览过这方面的知识,但是实际开发中却比较少用到; 其实多页面还是非常实用的,它可以用来实现组件库的功能预览、H5可视化系统的页面预览、个人站点的功能介绍等; 你可以直接跳到文末的仓库源码,也可以跟着本文逐步搭建一个vue-cli多页面应用 例如下面的网站,都可以用多页面应用来实现:: 有赞:Vant 饿了么:Mint-UI 京东:Nutui 实.

qq_44753311的博客 1100

vue cli3配置多页面入口

使用vue 配置多入口 因为懒,所以要提高开发效率,因为懒,所以要安装第三方依赖 使用glob自动加载 yarn add glob -D //安装依赖 配置vue.config.js const getEntries =(pathUrl)=>{ let pages={} glob.sync(pathUrl).map(filePath=>{ const fileName=filePath.substring(filePath.lastIndexOf(

qq_38461388的博客 1074

vue入门|ElementUI使用指南

vue入门|ElementUI使用指南 1.开发前务必熟悉的文档: vue.js2.0中文,项目所使用的js框架 vue-router,vue.js配套路由 vuex 状态管理 Element UI框架 2.构建项目框架 全局安装脚手架环境 npm install -g vue-cli 创建一个基于webpack模板项目my-project vue init webpack my-project 进入项目 cd my-project 安装依赖 npm install 启动项目 npm ru

new_Petrichor的博客 901

vue vite 多页面应用与vue cli多页面应用 (MPA)及其比较(避坑)

vue-cli和vite安装默认的应用后,对其进行多页面应用改造,总结vite多页面应用与cli多页面应用的异同点,实际需要和避坑总结。vue vite 多页面应用与vue cli多页面应用 (MPA、SPA)及其比较(避坑)

qq_51165365的博客 2747
上一篇: 我知道的前端算法
下一篇: 搭建公司自己的组件平台
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值