Any plan for docs of abstract components?
See original GitHub issueThere are several built-in abstract components, such as transition
, keep-alive
. However, the official guide doesn’t tell the developers that they could also create their own.
Here’s a possible use case. If the user’s network is very good, I may want to guess his/her behavior based on some rules, and prefetch some async data or routes. So I create a prefetch
abstract component. When the user really does what I have guessed, the UI could response immediately.
After read source code of the built-in abstract components, I found that there are pitfalls I didn’t realize. For example, an abstract component may contain another abstract component. Then I start to worry whether I could use it the right way.
Is abstract
designed to be internal only, or is there any plan for the docs?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top GitHub Comments
Hi, I asked a question on stackoverflow related to this issue. My use case is simple. I just want to have a component which will add a property to its child component but will not change html at all.
From this:
To this:
Hi. I have run into a case where this might be pretty useful. I’m new to Vue, so there may already be a good solution for what I’m presenting. I looked through the docs and through issues and didn’t see anything that might help.
I’m working on a project that uses canvas pretty extensively to draw graphs. I’ve worked with React where creating abstract components isn’t a problem. I guess that I assumed the case would be the same in Vue (not a criticism, Vue is the cat’s pajamas).
Let me explain the use case:
I’d like to make a series of components that encapsulate drawing operations to a canvas. Think:
<weighted-edge>
,<unidirectional-edge>
,<bidirectional-edge>
,<graph-node>
, etc. These nodes need simply to contain the logic for drawing to the canvas, hence no rendering new DOM elements. I originally sketched out a hierarchy like so, (before I painted myself into a corner):The idea is that a parent component handles the canvas and passes the context down into all the child abstract components, which handle drawing. My thinking is that this might provide a simple way of managing draw layers to the canvas and for maintaining drawing operation code. If you’ve ever worked on a project with lots of drawing, it usually ends up a pain to maintain.
My point is that some ‘view’ elements aren’t always DOM elements. The canvas is a pretty complex element and it’d be most excellent to use Vue components (and vuex) to manage the state of a canvas image. Having access to abstract components would make it somewhat easier to incorporate more robust drawing libraries as well.
Anywho, just my two cents.