vue-router

RouterLink attrs is readonly

自作多情 提交于 2020-01-02 03:53:05
问题 I'm starting with VueRouter in Vue.js and I'm getting this errors: [Vue warn]: $attrs is readonly. found in ---> <RouterLink> <SecondNav> at resources\assets\js\modules\livegame\player\SecondNav.vue <Player> at resources\assets\js\modules\livegame\player\Player.vue <Root> [Vue warn]: $listeners is readonly. found in ---> <RouterLink> <SecondNav> at resources\assets\js\modules\livegame\player\SecondNav.vue <Player> at resources\assets\js\modules\livegame\player\Player.vue <Root> I have reduced

Vue.js routes serving from subdirectory

狂风中的少年 提交于 2020-01-01 04:40:55
问题 I would like to serve my Vue.js app from a subdirectory on a staging server. For example: http://url.com/subdir/app/ Right now if I do this and set up the build config assetsPublicPath to serve from that folder, all the assets are served fine but my app does not get routed correctly. The "home" page gets routed to the 'catch-all', and any further routes simply show the normal white-page 404. Here is my router: export default new Router({ mode: 'history', routes: [ { path: '/', component:

Two Path with same route and same component - Vue js

梦想与她 提交于 2019-12-31 03:55:08
问题 I have two path with same component like this: /:loc("-host") - should match /usa-host /:loc/:sublocation("-host") - should match /usa/washington-host how to achieve this using single named route in vue.js 回答1: This is my solution. Router: Use ? to separate param from literal in route. const router = new VueRouter({ routes: [ { path: '/', component: Home }, { path: '/:loc/:subloc?-host', component: Location }, { path: '/:loc?-host', component: Location }, ] }) Component: Set local variables

Vue实例

自古美人都是妖i 提交于 2019-12-30 11:43:20
1绑定事件指令 v-on <button v-on:click="num++">点击1</button> <button @click="num++">点击2</button> <button @click="countSum()">点击3</button> <button @click="countSum">点击4</button> <button @click="say('今天天气好冷了')">点击5</button> <script> new Vue({ el:"#app", data:{ num:0 }, methods:{ countSum(){ this.num = this.num + 1 }, say(msg){ console.log(msg); } } }) </script> 2 计算属性 作用:可以代替的复杂的表达式 比如下面: <div id="app"> {{new Date(birthday).getFullYear() +"年"+new Date(birthday).getMonth()+"月"}} {{birth1}} {{getBirth1()}} </div> <script> new Vue({ el:"#app", data:{ num:0, birthday:1529032123201 }, methods:{ getBirth1(){

VueJs vue-router linking an external website

て烟熏妆下的殇ゞ 提交于 2019-12-30 08:12:27
问题 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: 回答1: <a :href="'//' +

Vue-router redirect on page not found (404)

霸气de小男生 提交于 2019-12-28 05:36:06
问题 I'm trying to redirect to 404.html on page not found using the router.beforeEach global hook, without much success (using Vue and Vue-Router 1.0): router.beforeEach(function (transition) { if (transition.to.path === '/*') { window.location.href = '/404.html' } else { transition.next() } }); This is not redirecting to page 404.html when a non-existing route is inserted, just giving me an empty fragment. Only when hard-coding some-site.com/* will it redirect to the expected some-site.com/404

Vue动态路由

和自甴很熟 提交于 2019-12-28 01:26:44
Vue动态路由 1、不同路由传值:动态路由 1、配置动态路由 routes: [ // 动态路径参数 以冒号开头 { path: '/user/:id', component: User } ] 2、在对应的页面 this.$route.params获取动态路由的值 var aid=this.$route.params.aid; this.$route.query //获取get传值 //第一种跳转方式 // this.$router.push({ path: 'news' }) // this.$router.push({ path: '/content/495' }); //另一种跳转方式 // { path: '/news', component: News,name:'news' }, // router.push({ name: 'news', params: { userId: 123 }}) this.$router.push({ name: 'news'}) https://router.vuejs.org/ vue路由配置: 1.安装 npm install vue-router --save / cnpm install vue-router --save 2、引入并 Vue.use(VueRouter) (main.js) import VueRouter

使用vue-cli搭建SPA项目

怎甘沉沦 提交于 2019-12-27 05:06:25
1、安装vue-cli 打开cmd命令 npm install -g vue-cli npm install -g webpack 然后进行安装,安装成功后你的node-v10.15.3-win-x64目录下的node_global会多出 vue vue.cmd vue-init vue-init.cmd vue-list vue-list.cmd的文件 安装完成之后打开命令窗口并输入 vue -V(注意这里是大写的“V”),如果出现相应的版本号,则说明安装成功。 然后再输入vue init webpack spa1 spa1即为项目名,项目名不能用中文或大写字母,然后终端会出现“一问一答”模式 1.Project name:项目名,默认是输入时的那个名称spa1,直接回车 2.Project description:项目描述,直接回车 3.Author:作者,随便填或直接回车 4.Vue build:选择题,一般选第一个 4.1Runtime + Compiler: recommended for most users//运行加编译,官方推荐,就选它了 4.2Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue

vue生态圈

霸气de小男生 提交于 2019-12-26 03:10:43
本文来自网易云社区 作者:刘凌阳 前言 公司社区上关于Vue的文章挺少的(少的可怜),不禁为Vue愤愤不平,此文应运而生。 但笔者水平有限,也写不了什么特别高深的东西,只能简单介绍下Vue生态圈,如有不对之处,还望指正。 Vue.js Vue.js是一款极简的 mvvm 框架,如果让我用一个词来形容它,就是“轻巧” 。如果用一句话来描述它,它能够集众多优秀逐流的前端框架之大成,但同时保持简单易用。为什么这么说,因为Vue.js通过简洁的API提供高效的数据绑定和灵活的组件系统。在前端纷繁复杂的生态中,Vue.js却一直受到一定程度的关注,而其本身也在高速发展中,不论是生态、社区、资源、插件等等都在日趋壮大。如果您还未曾了解Vue.js的话,建议您阅读 http://cn.vuejs.org/v2/guide/ ,这里有Vue.js正确的食用方法。如果您想在此文中知晓Vue.js核心的话,可能要让您失望了。本文不会介绍Vue.js的语法,模板、组件、API等等,这是一篇介绍Vue.js周边或者说Vue.js生态的文章(当然这要求你对Vue.js有一定程度的了解)。 Vuex 如果说整个生态圈里vue.js作为核心,坐实了老大地位的话,我会把Vuex放在老二的位置。学过React的人都知道Redux 的重要性,而Vuex之于Vue就像Redux之于React。 Vuex 是一个专为

Vue.js error : Cannot read property '_parent' of undefined(…)

喜你入骨 提交于 2019-12-25 04:25:42
问题 i am trying to use Vue.js global event bus. Here is my code. I checked lots of examples which are working fine but when i try to use the same idea to code for my project it's showing this Error: Cannot read property '_parent' of undefined(…) var bus = new Vue() Vue.component('login', { template: "#login", data: function(){ return { ip:'', sessiontoken:'' } }, ready: function(){ this.settoken(); this.getip(); }, methods: { getencrypteduser:function(){ }, getauthentifications: function(event){