vue-router

Non-scoped styling in components applied only once when switching routes

感情迁移 提交于 2019-12-02 06:34:10
Vue.js documentation for Scoped CSS mentions that You can include both scoped and non-scoped styles in the same component I built the example application for vue-router and used two single file components instead of the string templates of the example - the rendering is as expected. I then tried to apply both scoped and non-scoped styles in the components. In the first one I have <style scoped> div { color: white; background-color: blue; } </style> <style> body { background-color: green; } </style> and the second one <style scoped> div { color: white; background-color: red; } </style> <style>

Vue.js Router Query Array

好久不见. 提交于 2019-12-02 06:33:46
I'm trying to do is pass an array from query to the backend using Vue.js and router. So I have this method: submitForm () { this.$router.push({ name: 'AuctionResult', query: { models: this.selectedModels.map(e => e.value) } }) }, As a result will be query like this: ?models=MODEL1&models=MODEL2... But how can I make inputs look like array, like this: ?models[]=MODEL1&models[]=MODEL2... ??? I didn`t find anything in the documentation. To support PHP / array style multi-values, you can just set the key name to be what you want, ie query: { 'models[]': this.selectedModels.map(e => e.value) } This

Vue安装与简单使用

此生再无相见时 提交于 2019-12-02 05:01:17
发布于:2019-06-28 22:52 Vue入门 使用Typora打开 https://pan.baidu.com/s/1Mf3ZFSthdVUQevqWr777eA 提取码 hg9b vue中文官网教学 安装与使用,我也经常看这个 https://cn.vuejs.org/v2/guide/ Vue (读音 /vjuː/,类似于 view ) 是一套用于构建用户界面的 渐进式框架 安装Node.js 下载地址 https://nodejs.org/en/download/ 安装,直接下一步即可 安装完成查看node版本号 安装完成,node自带npm,查看npm版本号 安装nrm(镜像切换工具),输入命令,等待安装好就行了 查看所有镜像源 * 代表当前所选镜像源 如果不是 taobao 可以更换 taobao IDEA操作Vue IDEA安装vue插件 创建一个空工程 File>>>New>>>Project>>>Empty Project>>>Empty Project>>>Next>>>输入Project Name>>>Finish 创建一个Module File>>>New>>>Module>Static Web>>>Static Web>>>Next>>>输入Module Name>>>Finish 这时此Module还为空,打开IDEA最下面Terminal

vue-router之to属性赋值

笑着哭i 提交于 2019-12-02 04:37:42
to属性赋值 <!-- html --> <div id="app"> <router-link to="/bj/朝阳区">北京</router-link> <!-- 常规 --> <router-link to="/sh">上海-常规</router-link> <!-- 变量 --> <router-link :to="path">上海-变量</router-link> <!-- 对象path --> <router-link :to="{path:'/sh'}">上海-对象path</router-link> <!-- 对象name --> <router-link :to="{name:'b'}">上海-对象name</router-link> <!-- 对象name传值 --> <router-link :to="{name:'a', params:{placename:'丰台区'}}">北京-对象name传值</router-link> <router-view></router-view> </div> <!-- js --> <script src="./vue.js"></script> <script src="./vue-router.js"></script> <script> var router = new VueRouter({ routes: [ {

Vue 2 <keep-alive> not working with <router-view> and key

ⅰ亾dé卋堺 提交于 2019-12-02 03:51:59
I'm using vue-router with a series of components like tabs. Each <router-link> is a tab and the space below is the <router-view> . Two of the tabs are the same component with different filters, let's say they are products and the router adds a parameter for filtering: /products/new & /products/sale . Inside of products are individual product components which get mounted when the route is opened. My problem is that when I switch between the routes, and the filter parameter is changed, the product components get remounted every time. I'd like to cache them so switching back and forth is easier.

I use vue-router and jQuery in the template,when i switch router $(document).ready() is failure

五迷三道 提交于 2019-12-02 03:45:37
I do not know jQuery in vue correct usage. When I refresh page, $(document).ready() has a role. But when I switch the page through vue-router, $(document).ready() does not work. <template> <div id="photo_wrap"> <div class="photo_frame" v-for="(photo,index) in photos"> <img v-bind:src=" 'src/assets/photo/' + index + '.jpg' "> </div> </div> </template> <script> import $ from 'jquery' export default { name: 'photo', data() { return { photos: [ {},{},{},{},{} ] } } } $(function () { console.log('something') }) </script> Instead of relying on $(document).ready() in a vue webapp, you can use one of

Vue.js: vue-router subdomains

爱⌒轻易说出口 提交于 2019-12-02 00:29:33
问题 The vue-router documentation does not address this topic. Perhaps my expectation that vue-router could handle this illustrates a fundamental misunderstanding of mine of how subdomains operate. Could this be handled by vue-router, and if so, how, and if not, why not? 回答1: Nope, it's not possible. vue-router uses history.pushState, which doesn't allow you to change the origin. Quote from the docs: The new URL must be of the same origin as the current URL; otherwise, pushState() will throw an

vue-router 利用url传递参数

半城伤御伤魂 提交于 2019-12-01 23:38:19
vue-router 利用url传递参数   :冒号的形式传递参数   在路由配置文件里以:冒号的形式传递参数,这就是对参数的绑定。 1. 在配置文件里以冒号的形式设置参数。我们在/src/router/index.js文件里配置路由。 { path:'/params/:newsId/:newsTitle', component:Params } 我们需要传递参数是新闻ID(newsId)和新闻标题(newsTitle).所以我们在路由配置文件里制定了这两个值。 2. 在src/components目录下建立我们params.vue组件,也可以说是页面。我们在页面里输出了url传递的的新闻ID和新闻标题。 <template> <div> <h2>{{ msg }}</h2> <p>新闻ID:{{ $route.params.newsId}}</p> <p>新闻标题:{{ $route.params.newsTitle}}</p> </div> </template> <script> export default { name: 'params', data () { return { msg: 'params page' } } } </script> 来源: https://www.cnblogs.com/mmzuo-798/p/11721543.html

How to config nginx for Vue-router on Docker

妖精的绣舞 提交于 2019-12-01 22:19:41
I'm setting up a docker image from nginx to serve a Vue app as static files. My vue app uses Vue-Router and it works perfectly on an other server. My nginx config is just like this: https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations And now I wanna migrate to docker, and this is my Dockerfile # build stage FROM node:9.11.1-alpine as build-stage WORKDIR /app COPY package*.json ./ RUN npm install COPY . . RUN npm run build # production stage FROM nginx:1.15.8-alpine as production-stage COPY docker/nginx/prod.conf /etc/nginx/nginx.conf/prod.conf # [*] COPY -

VueJs vue-router linking an external website

自闭症网瘾萝莉.ら 提交于 2019-12-01 22:19:36
This may be simple, but I've looked over documentation and can't find anything about it. I want to have my 'github' link redirect to say, github.com. However, its just appending ' https://github.com ' to my url instead of following the link. Here is a snippet: <BreadcrumbItem to='https://github.com'> <Icon type="social-github"></Icon> </BreadcrumbItem> (This is using iView for custom CSS, but 'to' works in the same way as router-link). What ends up happening is this: I read Daniel's Link and found a workaround: { path: '/github', beforeEnter() {location.href = 'http://github.com'} } <a :href="