Giter VIP home page Giter VIP logo

Comments (4)

duckbox avatar duckbox commented on May 18, 2024

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.

yyx990803 avatar yyx990803 commented on May 18, 2024

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.

duckbox avatar duckbox commented on May 18, 2024

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.

ayamflow avatar ayamflow commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.