Comments (4)
Based on IRC discussions, vue-router will require a selector, acting as the stage for routeViews, routes and components.
Potentially looking like,
Vue.router('#container',{
'' : 'users',
'user/:id' : 'user',
'user/:id/edit' : 'edit-user'
});
Separate question regarding plugins, if something is not a Vue service ( directive, filter etc ). What is an acceptable way to expose this?
exports.install = function( Vue ) {
Vue.router = function( ops ){/*test*/};
}
from vue-router.
I think install
should be used only for registering global Vue assets.
Imagine a plugin that holds a bunch of utility directives. These directives should all be exposed in some way, together with the install
method which registers all of them globally via Vue.directive()
. This way the user can either use Vue.use(plugin)
to globally register everything, or cherry pick single directives from the plugin if needed.
For the case of router - I haven't made up my mind yet. I'll probably start on it this weekend and we'll see what feels right.
from vue-router.
No, I totally get you. Its how I approached mocking vue-import. Was just making sure as I'd imagine Router would not be a directive. Perfectly doable as you know, but feels wrong.
from vue-router.
I'm wondering about that too, I'm building a vue-router for my own purpose (& for learning) and was curious about which API would be the best. Currently I do:
app.config({
defaultRoute: 'home',
rootElement: '#view',
baseRoute: '/example'
});
app.route('/home', 'home-page'); // path, component
app.route('/about', 'about-page');
app.start();
I like @duckbox proposal though.
I'm sticking on an angular-like API for now, so each update of the route dispatch $locationChanged
/$routeChangeSuccess
events and maintain a global $location
-like object (which is basically a wrapped page.js context). Then I directly update the visible component according to the route. I was wondering if a v-route directive would be nice, in the spirit of angular ngView.
from vue-router.
Related Issues (20)
- Cant debug with vue-router HOT 1
- Vue 2.7 useRouter & Storybook HOT 1
- In navigation guards, it is possible to distinguish whether push triggers navigation or replace triggers navigation?
- 后面异步append加入的script没有插入iframe的head HOT 1
- vue-router is very nice HOT 1
- npm 和yarn 安装vue-router,useRoute 数据不一致 HOT 1
- 在微前端qiankun为基座的情况下,手动修改浏览器地址栏,两个子应用间设置的createWebHashHistory base会互相叠加 HOT 3
- Use dynamic routing prompts Uncaught Error: [vue-router] "path" is required in a route configuration HOT 1
- requested module '/node_modules/.vite/deps/vue-router.js?v=85d94ed7' does not provide an export named 'default' HOT 1
- Illegal character leads to lost all query data in "history" mode
- The history.state object lost certain properties because they were overwritten by the pushState function. HOT 1
- 两层iframe嵌套,在hash模式下,第二层iframe不渲染 HOT 2
- Page refreshing after replacing the current route ( Component getting unmounted and mounted again) HOT 2
- watch router or router.currentRoute.path question HOT 2
- Canonical Path for SEO tagging? HOT 7
- 4.1.5版本以上,单个路由配置beforeEnter 无效 HOT 1
- Detect when the user changes the URL on the address bar by manually typing it HOT 1
- check path 404 HOT 1
- In Vue vite, router.push() does not render page although it does navigate to a new URL HOT 1
- The type of query is wrong and may be undefined. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-router.