当前位置: 首页 > news >正文

四川省微信网站建设推广线上营销方式6种

四川省微信网站建设推广,线上营销方式6种,wordpress 过滤html代码,网上有多少个购物平台需求 我们这里分享一下关于Vue2和Vue3里面如何去掉浏览器路由里面#号的问题#xff0c;以及nginx的配置。 去掉#号问题之前我们先讨论一下html中的hash模式和history模式。 html中的hash模式 HTML的hash模式指的是URL中的锚点部分#xff08;#后面的内容#xff09;被用…需求 我们这里分享一下关于Vue2和Vue3里面如何去掉浏览器路由里面#号的问题以及nginx的配置。 去掉#号问题之前我们先讨论一下html中的hash模式和history模式。 html中的hash模式 HTML的hash模式指的是URL中的锚点部分#后面的内容被用于在单个页面中显示不同的内容而不是导航到不同的页面。 例如 https://example.com/#/supplierManage这里我们使用的#/supplierManage部分就是一个锚点用于在页面上显示关于页面的内容而不是导航到另一个新的页面的。 在使用hash模式时可以使用JavaScript监听hashchange事件以便在锚点改变时执行相应的操作。这种模式常用于单页面应用程序SPA其中所有页面内容都在同一个HTML页面中加载而不是通过导航到新页面来加载。此外hash模式还可以用于在不刷新整个页面的情况下更改URL以便在浏览器历史记录中创建可回退的状态。 html中的history模式、 HTML5中的History API允许使用JavaScript动态更新URL并在历史记录中保存状态而不会刷新整个页面。这就是所谓的“history模式”。它使用HTML5的pushState和replaceState方法来添加或修改浏览器历史记录中的条目。 在history模式下URL的路径部分会随着用户的操作而变化但实际页面内容不会刷新这使得Web应用程序更具交互性和可访问性。 如果浏览器支持History API那么就可以使用history.pushState()和history.replaceState()方法来更新浏览器的URL路径从而可以实现前端路由而不用像传统的多页面应用一样每次都请求服务器获取新的HTML页面。 一、vue2中的去除#号 我们在vue2中默认情况下出现#号的是因为Vue 的 router 默认是 hash 模式在 hash 模式下是会有#号在URL上 例如如你访问 https://www.baidu.com实际跳转 https://www.baidu.com/#/index 即它在路由时在每个路径前面都会带个#刷新时可能还会导致 404 1- 解决方案 1前端修改Vue配置的路由方式 在 router 的 index.js 页面内mode 默认是 hash修改为 history // 路由const router new VueRouter({mode: history,routes}) 2需要后端或运维技术人员帮忙修改 修改NGINX配置文件 增加try_files $uri $uri/ /index.html; location / {try_files $uri $uri/ /index.html; } 注意需要找到对应域名的nginx.comf来修改一般在 nginx/conf/vhosts 里面如果没有的话需要在 nginx/conf/nginx.conf 里面增加一个server 自定义静态资源文件夹 # 路径 location / {root /web-server/front-project/dist;try_files $uri $uri/ router;index index.html index.htm; } # router配置 location router {rewrite ^.*$ /index.html last; } # 静态资源代理 location /myblog_static {alias /web-server/front-project/dist//myblog_static/; } 3为了防止出现404访问不到问题vue打包 assetsPublicPath base 为绝对路径 / use strict; // Template version: 1.3.1 // see http://vuejs-templates.github.io/webpack for documentation.const path require(path);module.exports {dev: {// PathsassetsSubDirectory: myblog_static,assetsPublicPath: /,proxyTable: {/api/: {target: 后端接口地址, //后端接口地址ws: true, //接受websocket请求changeOrigin: true, //是否允许跨越chunkOrigins: true,pathRewrite: {^/api: api, //重写,},},},// Various Dev Server settingshost: localhost, // can be overwritten by process.env.HOSTport: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determinedautoOpenBrowser: false,errorOverlay: true,notifyOnErrors: true,poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-// Use Eslint Loader?// If true, your code will be linted during bundling and// linting errors and warnings will be shown in the console.useEslint: false,// If true, eslint errors and warnings will also be shown in the error overlay// in the browser.showEslintErrorsInOverlay: false,/*** Source Maps*/// https://webpack.js.org/configuration/devtool/#developmentdevtool: cheap-module-eval-source-map,// If you have problems debugging vue-files in devtools,// set this to false - it *may* help// https://vue-loader.vuejs.org/en/options.html#cachebustingcacheBusting: true,cssSourceMap: true,},build: {// Template for index.htmlindex: path.resolve(__dirname, ../dist/index.html),// PathsassetsRoot: path.resolve(__dirname, ../dist),assetsSubDirectory: myblog_static,assetsPublicPath: /,/*** Source Maps*/productionSourceMap: false,// https://webpack.js.org/configuration/devtool/#productiondevtool: #source-map,// Gzip off by default as many popular myblog_static hosts such as// Surge or Netlify already gzip all myblog_static assets for you.// Before setting to true, make sure to:// npm install --save-dev compression-webpack-pluginproductionGzip: true,productionGzipExtensions: [js, css],isIgnoreLogs:true,// 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 offbundleAnalyzerReport: process.env.npm_config_report,}, }; 配置完成后效果如下 二、vue3中的去除#号 1我们需要把createWebHashHistory变成createWebHistory import { createRouter, createWebHistory } from vue-routerconst router createRouter({history: createWebHistory(),routes: [//...], })2vue配置base import { defineConfig } from vite; import vue from vitejs/plugin-vue; // ts-ignore import { resolve } from path; // ts-ignore import Components from unplugin-vue-components/vite; // ts-ignore import { AntDesignVueResolver } from unplugin-vue-components/resolvers;// https://vitejs.dev/config/ export default defineConfig({// 打包相对路径base: /,server: {port: 3000,open: true,cors: true,proxy: {^/cloudApi/: {target: https://yongma16.xyz/back-front/,// target: http://localhost:9090/,changeOrigin: true,ws: true,rewrite: (path) path.replace(/^\/cloudApi/, ),},},},css: {preprocessorOptions: {less: {javascriptEnabled: true,patterns: [resolve(__dirname, ./src/style/main.less)],},},},resolve: {alias: {: resolve(__dirname, src),},},plugins: [vue(),Components({resolvers: [AntDesignVueResolver()],}),], }); 三、测试是否已经修改成功 为了方便配合验证我们刚才修改是否成功我们这里可以启动本地服务http-server可以运行vue项目看看有没有#号
http://www.hkea.cn/news/14296941/

相关文章:

  • 网站开发与维护能做什么职业区域门户网站源码
  • 山河建设集团有限公司的网站广告投放面试
  • 大尺度做爰后入网站怎么往公司网站添加
  • 综合门户型网站有哪些网站建设费用入账
  • flash网站策划书手机网站和app的区别
  • 东莞建网站公司品牌吉林省四平市建设局网站
  • 网站改版后 搜索不到青浦网站建设公司
  • 聊城做网站推广公司济宁市网站建设
  • 网站建设找丿金手指排名外包加工网官网下载安装
  • asp.net 4.0网站开发网络营销代运营服务
  • 行业网站定位品牌推广软文
  • 网站建设方案行业做网站的公司有哪些
  • 浙江网站建设哪里好建湖专业做网站
  • 网站建设明细报价表仅供参考微信 网页版
  • 网站上线前应该备案吗桂林市风尚网络科技有限公司
  • 有产品做推广,选哪个 网站学校网站模板免费
  • 东莞网站公司网站设计制作 一年价格
  • 用wp系统做网站互联网推广方法
  • 网站建设和网站推广可以同一家做吗江苏建设工程监督
  • 知道网站前台怎样进后台网站前端设计与实现
  • 做网站 多页面网址怎么弄广州seo培训机构
  • 网站建设 服务条款网站建设职业规划
  • 加强学校就业信息网站建设和管理网络规划设计师论文方向
  • 佛山市建设企业网站服务机构凡科建站视频教程
  • 网站网页设计怎样论坛网站html模板
  • 个人网站建设工作室wordpress 文章添加附件
  • 织梦网站地图在线生成织梦仿站建站网站建设实战
  • 网站建设电销职责找工作用什么平台最好
  • 南宁网站建设哪里有宁波微网站建设
  • 如何做国际网站产品宣传如何导入wordpress主题