Adding vue 3 to existing web forms ASPX page - asp.net

In vue 2, in order to incorporate vue into an existing web forms ASPX page you just had to add the proper script tag. Something like this :
<script src="https://cdn.jsdelivr.net/npm/vue#2.6.12"></script>
Can you do this with Vue 3? I've been researching how to incorporate vue 3 into existing web forms application, like ASPX pages, and can't find anything on it. Can anyone show me how to incorporate vue 3 into an ASPX page?

use this
<script src="https://unpkg.com/vue#next/dist/vue.global.prod.js"></script>
or
<script src="https://unpkg.com/vue#next/dist/vue.global.js"></script>
The Vue package makes multiple packages available:
vue.cjs.js
vue.cjs.prod.js
vue.esm-browser.js
vue.esm-browser.prod.js
vue.esm-bundler.js
vue.global.js
vue.global.prod.js
vue.runtime.esm-browser.js
vue.runtime.esm-browser.prod.js
vue.runtime.esm-bundler.js
vue.runtime.global.js
vue.runtime.global.prod.js
You'd pick whichever one work best, but the simplest way to go is to use the vue.global.js during development and vue.global.prod.js in prod
Example
const app = Vue.createApp({
template: document.getElementById("appTemplate").innerHTML
})
app.component('my-component', {
template: document.getElementById("componentTemplate").innerHTML,
props:{name:{default: "🤷‍♂️"}}
})
app.mount('#app')
<script src="https://unpkg.com/vue#next/dist/vue.global.prod.js"></script>
<div id="app"></div>
<template id="appTemplate">
<h1>APP</h1>
<my-component name="world"></my-component>
</template>
<template id="componentTemplate">
Hello {{name}}
</template>

Based on official docs you could use CDN as follows :
<script src="https://unpkg.com/vue#next"></script>

Related

In Vue 3 how do I reference a local resource when using a UI Framework (without "#")?

I am accustomed to using the "#" character in Vue 3 so the location will still be referenced after Vite build, as in the following example:
<img src="#/assets/picture.jpg" />
With custom components from UI Frameworks, I can't figure out how to reference my images anymore! The "#" no longer works, since it is rendering out the custom component.
Element Plus example:
<el-image src="#/assets/picture.jpg" />
I tried using various permutations without the "#" sign. I couldn't readily find the answer in Vue 3 docs or docs for Element Plus or Chakra UI frameworks, and it is a hard question to search for here.
Okay, I found out how this can work, but it's hardly a solution
<script setup>
import imageUrl from "#/assets/picture.jpg";
</script>
<template>
<div>
<el-image :src="imageUrl" />
</div>
</template>

How do I include external javascript file using thymeleaf?

I'm using Spring Boot / MVC and learning Thymeleaf.
Let's say i have my scripts on another server.
https://staticserver.com/main.js
I've added the '//staticserver.com' portion to my model as jsLocation.
I want to do something on the lines of:
<script src="${jsLocation}/main.js"></script>
which would render
<script src="//staticserver.com/main.js"></script>
<script th:src="|${jsLocation}/main.js|"></script>
You can include external js file like below :
<script th:src="source to your external JS"></script>
You can refer below thread for more details as your query also relates to model.
Thymeleaf external javascript file shares the module attributes with html file
if your js file in /resources/static/js/
<script th:src="#{/resources/static/js/fileName.js}"> </script>

Include Angular file in layout.cshtml

I want to include my angular file(Layout.js) inside my _Layout.cshtml.
So I added it at the end of the page like this:-
#section Scripts{
<script src="~/Angular_Files/Layout.js"></script>
}
This does work but only for the index page. Whenever I click on another link say course.cshtml, my angular file(Layout.js) doesn't get included.
PS: I tried to explain the best I can. Feel free if you need any more clarification.

Meteor app Development

When I use tag on my .html page to reduce my code visibility in Meteor app development. Instead of showing data of that correspondent template, it shows the name of the template..
For eg:
{{>season}}
<template name="season">
<ul><li>Summer</li></ul>
</template>
.. But unfortunately in output window it appears as {{> season}}
Maybe you did not startup your project.
You need to do this in console:
cd yourappname
meteor
I suggest you follow this tutorial to know how to startup your project:
https://www.meteor.com/try

Meteor: which first html file will iron-routing load

I'm creating a Meteor application. When first creating application, Meteor has put this sample code in hello.html
<head>
<title>hello</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> hello}}
</body>
<template name="hello">
Hello World Template
</template>
I install Iron-Router package. then here is my lib/Router.js file:
Router.route('/', function () {
this.render('post_template');
});
And here is my client/templates/posts/post_template.html
<template name="post_template">
Example Template
</template>
I don't know why when I run this application. The result is:
HelloWorld Template
Example Template
In other word, which part of Meteor's configuration that load hello.html as default page, and then append all other templates in routing inside ?
Thanks :)
In this case the very first Meteor loads is the
<body>
<h1>Welcome to Meteor!</h1>
{{> hello}}
</body>
Since you are calling there the hello template, thats the first you get on the screen.
I reccomend on this case use the layout template and remove the <body> tag
So first declare the route.
Router.configure({
layoutTemplate:'layout'
})
delete the <body> and <head> tags and place this layout template instead.
<template name="layout">
<navbar>
<!-- This stuff will be available on all routes since you are declaring on the layout template -->
</navbar>
{{> yield}} <!-- this yield helper will render the post_template or any other -->
</template>
For example
If you have this 2 routes.
Router.route('/', function () {
this.render('post_template');
});
Router.route('/example', function () {
this.render('example');
});
What happened here, when you go through the / route, iron router will render the 'post_template' html into the layout template, and when you navigate to /example, iron router will remove the post_Template html and render the content inside /example template, if you want to have the same content on all pages, declare it on the <layout> template i.e footers,navbars, etc
The layout template its like the "master" template here.
IR will append to the <body> if it exists (and otherwise add one for you) so it's recommended that you remove the entire <body> tag.
You are actually safe to remove the hello.html entirely (since you also don't need the hello template). If you want to keep the head tag, you could just modify the file to look like:
<head>
<title>hello</title>
</head>
To understand why hello.html is being included, see the Structuring your application section of your docs:
HTML files in a Meteor application are treated quite a bit differently from a server-side framework. Meteor scans all the HTML files in your directory for three top-level elements: <head>, <body>, and <template>. The head and body sections are separately concatenated into a single head and body, which are transmitted to the client on initial page load.
So all of your html files are always included. If you don't want to include them, you need to remove them from your app.

Resources