where to place dynamic nav component code using vue? - javascript

I am new in vue. I have a dynamic nav, which look like this:
<nav>home/news/setting</nav>
The content in nav may change dynamically on different url(I am using vue-router, too). Now, I have a file named Nav.vue. But I don't know where should I use this Nav.vue component.Should I use it in <App/> or should I write a decorator like makeNav(element) and composite it with all my pages?

Related

How to invoke Quasar dialog from external component?

I'm using Vue.js 2.x + Quasar 1.x with http-vue-loader (so no build tools) at the moment.
I put a q-dialog in a separate component - let's call it MyComponent, and when I just hook it up in a parent component like so:
<my-component></my-component>
then nothing happens, it's not even in the DOM... When I just insert the whole q-dialog template into the parent component, without having its separate external component, everything works just fine with a simple v-model.
So I imported the component successfully, that part is fine.
I was trying to invoke it when I click on a button, but I can't really communicate with the component this way.
Now I've come across two separate ways of creating dialogs in Quasar, the first one is using the component when it's not in its separate component. The second one seems to be the one I might need for a separate dialog component. The problem is that importing an external component with vue-http-loader looks like this:
components: {
'my-component': httpVueLoader('/components/MyComponent.vue'),
},
while according to the Quasar docs, it should look like this:
import CustomComponent from '..path.to.component..'
...
this.$q.dialog({
component: CustomComponent,
...
The docs are a bit confusing to me as well. :/
Unfortunately, I can't see the CustomComponent code, which is required to be created following an interface, which is described in this docpage under the warning. Make sure that CustomComponent is valid.
P.S. - Both of those ways do the same thing but in different ways. With the first one, you'll import that component to another and set him in the template, but with the second one, you'll call a tool, that creates a new modal with passed parameters. But the second one doesn't have all functionality compared to the first one.

Make a layout with material-ui

I don't know how to make a layout with a child page like this with material-ui. How do I build this?
If you know how to setup angularjs, you also can setup material-ui.
Same angularjs. [ index file - setup data-ng-app="myapp" in html tag
for router use ui-router
setup app.js
use
for ui aesthetic
make individual view same all like angularjs
And whatever styling you want use material ui, as the document says.
For styling you can use material-ui grid, then you can use React Router Link or something else and wrap the elements inside the Link (and set the Route in App.js if you use React Router). If you want your page as a child component, just import it as a component to the parent component and return it in the DOM.

How to add react component inside .Net aspx page

I have one react app which provides multiple components like <Button> <Label>. I want to render those component inside apsx page.
For example.
<div>
<ReactComponent/>
</div>
I know we can use iframe in aspx page to render react app or #script.render in cshmtl file. But am looking for some another way to render inside aspx page.
am new to dot net. I have created one ASP.Net web Application using MS visual studio.Any help would be really helpful..
Got this github link for this. enter link description here
Now I want to understand how I can add multiple react components, webpack, babel, package.json etc.
You could create a with a class (e.g. "react-component") and then in your JS code do the following:
ReactDOM.render(, document.querySelector('react-component'));

How to deal with components inside dynamic html strings in Sapper & Svelte?

I am trying to make my first Sapper site and I'm populating the content similarly to how it's done in the template here.
My problem is that I want to allow usage of custom components in the content of {#html post.html}. Currently it doesn't work, the HTML is just inserted there without being treated like a component, even if I import the component in [slug].html and it works if used directly somewhere besides that {#html post.html}.
The behaviour is kind of expected as the content is fetched after svelte has finished it's work, but I am not sure what should I do then. I want a couple of custom components like <FancyButton> to be usable in the user generated content.
Can I ask the [slug].html component to look at the post.html or just whole content after insertion and create an instance of child component wherever it should be? Or should I somehow compile the string beforehand on the server?

Add arbitrary Vue.js components to parent component

I'm using Vue.js to build ui for my html5 game. I have a case where I want to define ui-containers which essentially just group other ui-components and position them to somewhere on screen. So I could have something like this going on:
<ui-container>
<ui-component1></ui-component1>
<ui-component2></ui-component2>
<ui-component3></ui-component3>
</ui-container>
Where I need to add and remove those components dynamically based on data-model which represents the content of the container. The problem is that I'd like to keep ui-container generic, so that I can append any Vue-component to it without having information in template about which components there might be.
I googled and found this example which concerns injecting components dynamically: http://forum.vuejs.org/topic/349/injecting-components-to-the-dom
While the data-driven version in example was easy to make and understand, it uses v-for for tag and therefore requires one to know before hand the type of child-component.
So question is, how I can generalize that example to work with any component dynamically? Should my data-model have the type of component or tag name of it and then interpolate it in v-for? Or is there existing mechanism for this kind of requirement?
You can use special is attribute to dynamically set the type of a component. Here are the docs. The code will look somewhat like:
<div id="app">
<div v-for="component in components" :is="component.type" :value="component.value"></div>
</div>
Working fiddle to play with: Dynamic Vue.js components

Categories

Resources