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

某网站自己做中性笔企业为何选择网站推广外包?

某网站自己做中性笔,企业为何选择网站推广外包?,网站建设项目推进表,做羞羞事的网站有哪些学习源码可以看我的个人前端学习笔记 (github.com):qdxzw/frontlearningNotes 觉得有帮助的同学,可以点心心支持一下哈(笔记是根据b站上学习的尚硅谷的前端视频【张天禹老师】,记录一下学习笔记,用于自己复盘,有需要学…

学习源码可以看我的个人前端学习笔记 (github.com):qdxzw/frontlearningNotes

觉得有帮助的同学,可以点心心支持一下哈(笔记是根据b站上学习的尚硅谷的前端视频【张天禹老师】,记录一下学习笔记,用于自己复盘,有需要学习的可以去b站学习原版视频)

路由

一、对路由的理解

二、基本切换效果

  • Vue3中要使用vue-router的最新版本,目前是4版本。
  • 路由配置文件代码如下:
import { createRouter, createWebHistory } from "vue-router";
import Home from "../pages/Home.vue";
import News from "../pages/News.vue";
import About from "../pages/About.vue";const router = createRouter({history: createWebHistory(),routes: [{path: "/home",component: Home,},{path: "/news",component: News,},{path: "/about",component: About,},],
});
export default router;
  • main.ts代码如下:
// 引入createApp用于创建应用(买个盆)
import { createApp } from "vue";
import router from "./router/index";
// 引入App根组件(买个根)
import App from "./App.vue";
const app = createApp(App);
app.use(router);
app.mount("#app");
  • App.vue代码如下
<template><div class="app"><h2 class="title">Vue路由测试</h2><!-- 导航区 --><div class="navigate"><RouterLink to="/home" active-class="active"><span>首页</span></RouterLink><RouterLink to="/news" active-class="active"><span>新闻</span></RouterLink><RouterLink to="/about" active-class="active"><span>关于</span></RouterLink></div><!-- 展示区 --><div class="main-content"><RouterView></RouterView></div></div>
</template><script lang="ts" setup name="App">
import { RouterLink, RouterView } from 'vue-router'
</script><style scoped>
.title {text-align: center;
}
.navigate {width: 500px;text-align: center;margin: 0 auto;
}
.navigate span {display: inline-block;margin-right: 50px;width: 100px;height: 50px;line-height: 50px;background-color: blanchedalmond;text-decoration: none;/* color: ; */
}
.main-content {margin: 20px auto;text-align: center;width: 500px;height: 200px;border: 10px solid;background-color: aqua;
}
.active {color: salmon;
}
</style>

三、两个注意点

  1. 路由组件通常存放在pages 或 views文件夹,一般组件通常存放在components文件夹。
  2. 通过点击导航,视觉效果上“消失” 了的路由组件,默认是被卸载掉的,需要的时候再去挂载

四、路由器工作模式

  1. history模式优点:URL更加美观,不带有#,更接近传统的网站URL。缺点:后期项目上线,需要服务端配合处理路径问题,否则刷新会有404错误。
const router = createRouter({history:createWebHistory(), //history模式/******/
})
  1. hash模式优点:兼容性更好,因为不需要服务器端处理路径。缺点:URL带有#不太美观,且在SEO优化方面相对较差。
const router = createRouter({history:createWebHashHistory(), //hash模式/******/
})

五、to的两种写法

字符串、对象

<!-- 第一种:to的字符串写法 -->
<router-link active-class="active" to="/home">主页</router-link><!-- 第二种:to的对象写法 -->
<router-link active-class="active" :to="{path:'/home'}">Home</router-link>

六、命名路由

作用:可以简化路由跳转及传参(后面就讲)。

给路由规则命名:

routes:[{name:'zhuye',path:'/home',component:Home},{name:'xinwen',path:'/news',component:News,},{name:'guanyu',path:'/about',component:About}
]

跳转路由:

<!--简化前:需要写完整的路径(to的字符串写法) -->
<router-link to="/news/detail">跳转</router-link><!--简化后:直接通过名字跳转(to的对象写法配合name属性) -->
<router-link :to="{name:'guanyu'}">跳转</router-link>

七、嵌套路由

  1. 编写News的子路由:Detail.vue
  2. 配置路由规则,使用children配置项:
const router = createRouter({history:createWebHistory(),routes:[{name:'zhuye',path:'/home',component:Home},{name:'xinwen',path:'/news',component:News,children:[{name:'xiang',path:'detail',component:Detail}]},{name:'guanyu',path:'/about',component:About}]
})
export default router
  1. 跳转路由(记得要加完整路径):
<router-link to="/news/detail">xxxx</router-link>
<!-- 或 -->
<router-link :to="{path:'/news/detail'}">xxxx</router-link>
  1. 记得去News组件中预留一个<router-view>
<template><div class="news"><!-- 导航区 --><ul><li v-for="news in newsList" :key="news.id"><RouterLink to="/news/detail">{{ news.title }}</RouterLink></li></ul><div class="news-detail"><RouterView /></div></div>
</template><script lang="ts" setup name="News">
import { reactive } from 'vue'
import { RouterLink, RouterView } from 'vue-router'
let newsList = reactive([{ id: 'dawd1', title: '1', content: '11' },{ id: 'dawd2', title: '2', content: '22' },{ id: 'dawd3', title: '3', content: '33' }
])
</script>

八、路由传参

query参数

  1. 传递参数(query参数可以用path和name)
<!-- 跳转并携带query参数(to的字符串写法) -->
<router-link to="/news/detail?a=1&b=2&content=欢迎你">跳转
</router-link><!-- 跳转并携带query参数(to的对象写法) -->
<RouterLink :to="{//name:'xiang', //用name也可以跳转path:'/news/detail',query:{id:news.id,title:news.title,content:news.content}}"
>{{news.title}}
</RouterLink>
  1. 接收参数:
import {useRoute} from 'vue-router'
const route = useRoute()
// 打印query参数
console.log(route.query)

params参数

路由配置(如果传递的参数不是必须的,在后面加个?):

{name: "xinwen",path: "/news",component: News,children: [{name: "xiang",path: "detail/:id/:title/:content",component: Detail,},],},
  1. 传递参数(params参数只能用name)
<!-- 跳转并携带params参数(to的字符串写法) -->
<RouterLink :to="`/news/detail/001/新闻001/内容001`">{{news.title}}</RouterLink><!-- 跳转并携带params参数(to的对象写法) -->
<RouterLink :to="{name:'xiang', //用name跳转params:{id:news.id,title:news.title,content:news.title}}"
>{{news.title}}
</RouterLink>
  1. 接收参数:
import {useRoute} from 'vue-router'
const route = useRoute()
// 打印params参数
console.log(route.params)

备注1:传递params参数时,若使用to的对象写法,必须使用name配置项,不能用path。

备注2:传递params参数时,需要提前在规则中占位。

九、路由的props配置

作用:让路由组件更方便的收到参数(可以将路由参数作为props传给组件)

{name: "xiang",path: "detail/:id/:title/:content",component: Detail,// 第一种(传递值给路由组件):props的对象写法,作用:把对象中的每一组key-value作为props传给Detail组件// props:{a:1,b:2,c:3},// 第二种(只适用于props):props的布尔值写法,作用:把收到了每一组params参数,作为props传给Detail组件// props:true// 第三种(适用于props、query):props的函数写法,作用:把返回的对象中每一组key-value作为props传给Detail组件props(route) {return route.query;},},

使用defineProps进行接收

<template><ul><li>编号:{{ id }}</li><li>标题:{{ title }}</li><li>内容:{{ content }}</li></ul>
</template><script lang="ts" setup name="Detail">
defineProps(['id', 'title', 'content'])
</script>

十、 replace属性

  1. 作用:控制路由跳转时操作浏览器历史记录的模式。
  2. 浏览器的历史记录有两种写入方式:分别为push和replace:
    • push是追加历史记录(默认值)。
    • replace是替换当前记录。
  1. 开启replace模式:<RouterLink replace .......>News</RouterLink>

十一、编程式导航

路由组件的两个重要的属性:$route和$router变成了两个hooks

<template><div class="news"><!-- 导航区 --><ul><li v-for="news in newsList" :key="news.id"><!-- <RouterLink to="/news/detail">{{ news.title }}</RouterLink> --><!-- 跳转并携带params参数(to的字符串写法) --><!-- <RouterLink :to="`/news/detail/001/新闻001/内容001`">{{news.title}}</RouterLink> --><!-- 跳转并携带params参数(to的对象写法) --><button @click="showNewsDetail(news)">点击查看新闻</button><RouterLink:to="{name: 'xiang', //用name跳转params: {id: news.id,title: news.title,content: news.title}}">{{ news.title }}</RouterLink></li></ul><div class="news-detail"><RouterView /></div></div>
</template><script lang="ts" setup name="News">
import { reactive } from 'vue'
import { RouterLink, RouterView, useRouter } from 'vue-router'
let newsList = reactive([{ id: 'dawd1', title: '1', content: '11' },{ id: 'dawd2', title: '2', content: '22' },{ id: 'dawd3', title: '3', content: '33' }
])
const router = useRouter()
interface NewsInter {id: stringtitle: stringcontent: string
}
function showNewsDetail(news: NewsInter) {router.replace({name: 'xiang', //用name跳转params: {id: news.id,title: news.title,content: news.title}})
}
</script>

十二、重定向

  1. 作用:将特定的路径,重新定向到已有路由。
  2. 具体编码:
{path:'/',redirect:'/about'
}


文章转载自:
http://speedboat.c7497.cn
http://womanity.c7497.cn
http://kampuchea.c7497.cn
http://slavicize.c7497.cn
http://beehive.c7497.cn
http://disseizee.c7497.cn
http://pneumatometer.c7497.cn
http://resaid.c7497.cn
http://electrosurgery.c7497.cn
http://volatility.c7497.cn
http://denaturalize.c7497.cn
http://prototherian.c7497.cn
http://a.c7497.cn
http://gallicism.c7497.cn
http://carnelian.c7497.cn
http://mummification.c7497.cn
http://saxon.c7497.cn
http://jibb.c7497.cn
http://airglow.c7497.cn
http://singulative.c7497.cn
http://natationist.c7497.cn
http://ophicleide.c7497.cn
http://workingman.c7497.cn
http://lividity.c7497.cn
http://reengineer.c7497.cn
http://liabilities.c7497.cn
http://massy.c7497.cn
http://absquatulater.c7497.cn
http://restore.c7497.cn
http://cokehead.c7497.cn
http://unpatented.c7497.cn
http://grumpish.c7497.cn
http://apriority.c7497.cn
http://spiderlike.c7497.cn
http://leah.c7497.cn
http://lander.c7497.cn
http://biliprotein.c7497.cn
http://haiduk.c7497.cn
http://venae.c7497.cn
http://galosh.c7497.cn
http://metastasian.c7497.cn
http://faithless.c7497.cn
http://pentagynous.c7497.cn
http://thereinafter.c7497.cn
http://spinor.c7497.cn
http://equicaloric.c7497.cn
http://phytocoenosis.c7497.cn
http://whisper.c7497.cn
http://bathhouse.c7497.cn
http://semimillenary.c7497.cn
http://sumpter.c7497.cn
http://aborative.c7497.cn
http://neatness.c7497.cn
http://laical.c7497.cn
http://lech.c7497.cn
http://erythropsia.c7497.cn
http://enigmatize.c7497.cn
http://summable.c7497.cn
http://inflective.c7497.cn
http://eaves.c7497.cn
http://unfixed.c7497.cn
http://acinar.c7497.cn
http://highlighted.c7497.cn
http://santalaceous.c7497.cn
http://autocorrelator.c7497.cn
http://portentous.c7497.cn
http://ayrshire.c7497.cn
http://inlier.c7497.cn
http://strapontin.c7497.cn
http://intrada.c7497.cn
http://lackwit.c7497.cn
http://groundling.c7497.cn
http://tuxedo.c7497.cn
http://berried.c7497.cn
http://maynard.c7497.cn
http://googolplex.c7497.cn
http://hydroxyproline.c7497.cn
http://degranulation.c7497.cn
http://piliated.c7497.cn
http://othello.c7497.cn
http://equicontinuous.c7497.cn
http://hypnic.c7497.cn
http://meropia.c7497.cn
http://skinch.c7497.cn
http://hombre.c7497.cn
http://dipsomania.c7497.cn
http://tailpipe.c7497.cn
http://modulator.c7497.cn
http://moke.c7497.cn
http://gerontotherapeutics.c7497.cn
http://amalgam.c7497.cn
http://chemiculture.c7497.cn
http://coptic.c7497.cn
http://squeal.c7497.cn
http://vituperate.c7497.cn
http://crunkle.c7497.cn
http://petitioner.c7497.cn
http://energetically.c7497.cn
http://voyvodina.c7497.cn
http://appalling.c7497.cn
http://www.zhongyajixie.com/news/81533.html

相关文章:

  • Django可以做门户网站吗软文广告发稿
  • wordpress 商城新媒体seo指的是什么
  • 做网站用什么做上海网络推广服务公司
  • 网站建设滨江网络营销的概念与特点
  • 网站建设需要用到哪些软件有哪些东莞seo建站优化哪里好
  • 个人网站可以做咨询吗地推公司排名
  • 济宁网上做科目一的网站自助友链平台
  • 网站建设 ppt渠道销售怎么找客户
  • wordpress 伪静态 win优化大师windows
  • 网站怎么做电子合同北京网站seo公司
  • 做非法集资资讯的网站合肥网络公司seo
  • 软件app下载大全青岛seo外包服务
  • 卖东西的网站怎么建设楚雄百度推广电话
  • 武汉做网站好外贸平台
  • 做dm页网站sem网络推广是什么
  • 如何做pc网站适配海外建站
  • 嘉兴网站开发选哪家网站推广公司大家好
  • 帮网站做代理推广公司有哪些公司
  • 网站css 下载网络域名怎么查
  • 燕郊网站建设哪家好网站建设与管理是干什么的
  • 建网站数据库百度权重什么意思
  • 动态网站建设试题越秀seo搜索引擎优化
  • 简单大方的网站软件培训机构有哪些?哪个比较好
  • wordpress 自定义菜单设置合肥百度seo排名
  • 商务网站欣赏郑州整站网站优化
  • 网站右键屏蔽国内哪个搜索引擎最好用
  • 网站制作比较好的公司百度搜索排名靠前
  • 营销型网站建设定制seo咨询顾问
  • 小说网站开发多少钱搜索引擎优化排名
  • 定州市住房保障和城乡建设局网站网络营销试卷及答案