DAY 01 - 100 Days With Vue
https://dev.to/tahsin52225/day-01-100-days-with-vue-22fb
At last, I have started to learn Vue.js. Well, starting is the hard part of learning. Today I have learned about how to integrate Vue CDN and add Vue property to your project.
It's simple just add Vue CDN at the end of your Html file. Vue is ready for use.
Vue CDN
<script src="https://unpkg.com/vue@next" defer></script>
Adding Vue property in a particular HTML section
In your app.js (External JS file) file you have to create a Vue app and mount it into a particular section. Well you can use a variable to declare the Vue app
const app = Vue.createApp({});
To add this Vue app into your HTML code you need to use the mount function to this object. Mount accepts a string value of a CSS selector in which this Vue code applies. Here we have a section that has an id named #user-goal
const app = Vue.createApp({});
app.mount('#user-goal');
Nice ! Vue is mounted on that section
"data" property of Vue object
"data" is a predefined property of the Vue object which holds all the variables of the Vue app. "data" property always returns an object which holds a collection of variable names and values in a key-value pair. the variable value can be anything String, Number
, Boolean etc.
const app = Vue.createApp({
data(){
return {
variable_name : "variable_value"
}
}
});
app.mount('#user-goal');
"Interpolations" Showing data property value
"Interpolations" is a fancy name of handlebars, if you want to show your variable value into HTML. Just use double curly braces and write the variable name which you had declared on the data property.
<p>{{ variable_name }}</p>
"Interpolations" tells Vue to replace the variable name with the actual value of it. so you can't use "Interpolations" outside Vue mounted section.
"v-bind" attribute of Vue
Well, sometimes we need to pass value to Html attribute. For example, let's say you want to return a link to an anchor tag 'href' attribute, but if you use "Interpolations" it won't work. You need to use the "v-bind" attribute for that.
"v-bind" is a Vue attribute that helps to bind any Html attribute to Vue variables. Example :
<p> <a v-bind:href="variable_name">Link </a></p>
P.S: There are more uses of v-bind and we can use the shorter version of v-bind, But for now, let's stick with this.
"v-html" attribute of Vue
Now let's say you want to show an Html code using a variable. If you use only "Interpolations" it will show markup value and won't fulfill the purpose. For that, you need to use v-html attribute.
Example:
In app.js
const app = Vue.createApp({
data(){
return {
variable_name : "<h1> Hello this is value </h1>"
}
}
});
app.mount('#user-goal');
In index.html
<p v-html="variable_name"></p>
"methods" property of Vue object
Till now, we have used only static data. We need to add some dynamic feel to it. To do this, we need to use the "methods" property of the Vue object. "methods" is a predefined property that accepts only JS objects that hold the collection of functions.
const app = Vue.createApp({
data(){
return {
variable_name : "<h1> Hello this is value </h1>"
}
},
methods: {
function_name: function () {
//do something
}
}
});
app.mount('#user-goal');
We can use direct methods in "Interpolations"
In index.html
<p> {{ function_name() }}</p>
Use "data" property into "methods"
Basically we need to use variable into methods for that we just need to use "$this" keyword.
const app = Vue.createApp({
data(){
return {
variable_name : "<h1> Hello this is value </h1>"
}
},
methods: {
function_name: function () {
$this.variable_name = "new value"
}
}
});
app.mount('#user-goal');
Github Practice Code
Tahsin-Ahmed52225
/
100days-with-Vue
https://dev.to/tahsin52225/day-01-100-days-with-vue-22fb
At last, I have started to learn Vue.js. Well, starting is the hard part of learning. Today I have learned about how to integrate Vue CDN and add Vue property to your project.
It's simple just add Vue CDN at the end of your Html file. Vue is ready for use.
Vue CDN
<script src="https://unpkg.com/vue@next" defer></script>
Adding Vue property in a particular HTML section
In your app.js (External JS file) file you have to create a Vue app and mount it into a particular section. Well you can use a variable to declare the Vue app
const app = Vue.createApp({});
To add this Vue app into your HTML code you need to use the mount function to this object. Mount accepts a string value of a CSS selector in which this Vue code applies. Here we have a section that has an id named #user-goal
const app = Vue.createApp({});
app.mount('#user-goal');
Nice ! Vue is mounted on that section
"data" property of Vue object
"data" is a predefined property of the Vue object which holds all the variables of the Vue app. "data" property always returns an object which holds a collection of variable names and values in a key-value pair. the variable value can be anything String, Number
, Boolean etc.
const app = Vue.createApp({
data(){
return {
variable_name : "variable_value"
}
}
});
app.mount('#user-goal');
"Interpolations" Showing data property value
"Interpolations" is a fancy name of handlebars, if you want to show your variable value into HTML. Just use double curly braces and write the variable name which you had declared on the data property.
<p>{{ variable_name }}</p>
"Interpolations" tells Vue to replace the variable name with the actual value of it. so you can't use "Interpolations" outside Vue mounted section.
"v-bind" attribute of Vue
Well, sometimes we need to pass value to Html attribute. For example, let's say you want to return a link to an anchor tag 'href' attribute, but if you use "Interpolations" it won't work. You need to use the "v-bind" attribute for that.
"v-bind" is a Vue attribute that helps to bind any Html attribute to Vue variables. Example :
<p> <a v-bind:href="variable_name">Link </a></p>
P.S: There are more uses of v-bind and we can use the shorter version of v-bind, But for now, let's stick with this.
"v-html" attribute of Vue
Now let's say you want to show an Html code using a variable. If you use only "Interpolations" it will show markup value and won't fulfill the purpose. For that, you need to use v-html attribute.
Example:
In app.js
const app = Vue.createApp({
data(){
return {
variable_name : "<h1> Hello this is value </h1>"
}
}
});
app.mount('#user-goal');
In index.html
<p v-html="variable_name"></p>
"methods" property of Vue object
Till now, we have used only static data. We need to add some dynamic feel to it. To do this, we need to use the "methods" property of the Vue object. "methods" is a predefined property that accepts only JS objects that hold the collection of functions.
const app = Vue.createApp({
data(){
return {
variable_name : "<h1> Hello this is value </h1>"
}
},
methods: {
function_name: function () {
//do something
}
}
});
app.mount('#user-goal');
We can use direct methods in "Interpolations"
In index.html
<p> {{ function_name() }}</p>
Use "data" property into "methods"
Basically we need to use variable into methods for that we just need to use "$this" keyword.
const app = Vue.createApp({
data(){
return {
variable_name : "<h1> Hello this is value </h1>"
}
},
methods: {
function_name: function () {
$this.variable_name = "new value"
}
}
});
app.mount('#user-goal');
Github Practice Code
Tahsin-Ahmed52225
/
100days-with-Vue
DEV Community
DAY 01 - 100 Days With Vue
At last, I have started to learn Vue.js. Well, starting is the hard part of learning. Today I have...
An explosion of confetti as a Vue 3 component
https://vuejsexamples.com/an-explosion-of-confetti-as-a-vue-3-component/
An explosion of confetti as a Vue 3 component
https://vuejsexamples.com/an-explosion-of-confetti-as-a-vue-3-component/
An explosion of confetti as a Vue 3 component
The Web App that helps you to mange the Tech Communities
https://vuejsexamples.com/the-web-app-that-helps-you-to-mange-the-tech-communities/
The Web App that helps you to mange the Tech Communities
https://vuejsexamples.com/the-web-app-that-helps-you-to-mange-the-tech-communities/
The Web App that helps you to mange the Tech Communities
A Sticky Slider Example For Vue
https://vuejsexamples.com/a-sticky-slider-example-for-vue/
A Sticky Slider Example For Vue
https://vuejsexamples.com/a-sticky-slider-example-for-vue/
A Sticky Slider Example For Vue
Add a Github corner to your project page, This GitHub corner for Vue 3.0+ component
https://vuejsexamples.com/add-a-github-corner-to-your-project-page-this-github-corner-for-vue-3-0-component/
Add a Github corner to your project page, This GitHub corner for Vue 3.0+ component
https://vuejsexamples.com/add-a-github-corner-to-your-project-page-this-github-corner-for-vue-3-0-component/
Add a Github corner to your project page, This GitHub corner for Vue 3.0+ component
An Ordering System For A Hamburger Shop With Vue.js
https://vuejsexamples.com/an-ordering-system-for-a-hamburger-shop-with-vue-js/
An Ordering System For A Hamburger Shop With Vue.js
https://vuejsexamples.com/an-ordering-system-for-a-hamburger-shop-with-vue-js/
An Ordering System For A Hamburger Shop With Vue.js
A portfolio for developers with a blog powered by Notion
https://vuejsexamples.com/a-portfolio-for-developers-with-a-blog-powered-by-notion/
A portfolio for developers with a blog powered by Notion
https://vuejsexamples.com/a-portfolio-for-developers-with-a-blog-powered-by-notion/
A portfolio for developers with a blog powered by Notion
Vue admin dashboard template with stylish transparent design
https://vuejsexamples.com/vue-admin-dashboard-template-with-stylish-transparent-design/
Vue admin dashboard template with stylish transparent design
https://vuejsexamples.com/vue-admin-dashboard-template-with-stylish-transparent-design/
Vue admin dashboard template with stylish transparent design
Portfolio starter theme for Gridsome and Forestry
https://vuejsexamples.com/portfolio-starter-theme-for-gridsome-and-forestry/
Portfolio starter theme for Gridsome and Forestry
https://vuejsexamples.com/portfolio-starter-theme-for-gridsome-and-forestry/
Portfolio starter theme for Gridsome and Forestry
How to create dynamic input using Vue
https://dev.to/snehalk/how-to-create-dynamic-input-using-vue-2hf7
Hello Readers,
In this blog, I am going to show you, how we can create dynamic input using vuejs.
First, create a component and name it as DynamicInput.vue and add the below code.
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<div class="w-full mt-4 p-10">
<button
type="button"
class="flex justify-start ml-2 rounded-md border px-3 py-2 bg-pink-600 text-white"
@click="addMore()"
>
Add More
</button>
<div v-for="(course, index) in courses" :key="index">
<div class="flex justify-start ml-2 mt-4">
<input
v-model="course.courseName"
class="w-full py-2 border border-indigo-500 rounded"
/>
<button
type="button"
class="ml-2 rounded-md border px-3 py-2 bg-red-600 text-white"
@click="remove(index)"
v-show="index != 0"
>
Remove
</button>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "HelloWorld",
props: {
msg: String,
},
data() {
return {
courses: [
{
courseName: "",
},
],
};
},
methods: {
addMore() {
this.courses.push({
courseName: "",
});
},
remove(index) {
this.courses.splice(index, 1);
},
},
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
Now add this component into App.vue file as below.
<template>
<div id="app">
<DynamicInput msg="Example of Dynamic Input" />
</div>
</template>
<script>
import DynamicInput from "./components/DynamicInput";
export default {
name: "App",
components: {
DynamicInput,
},
};
</script>
<style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
I have installed tailwind CSS to styling you have to install it.
If you like my post please follow me to get more blog posts.
.ltag__user__id__672647 .follow-action-button {
background-color: #9f0b46 !important;
color: #ffffff !important;
border-color: #9f0b46 !important;
}
Snehal Follow
Software Developer by Profession, mostly works in Laravel | Vue JS | Nuxt JS | PHP | Javascript | InertiaJS.
For more details you can refer below codesandbox.
Happy Reading. 🦄 ❤️
https://dev.to/snehalk/how-to-create-dynamic-input-using-vue-2hf7
Hello Readers,
In this blog, I am going to show you, how we can create dynamic input using vuejs.
First, create a component and name it as DynamicInput.vue and add the below code.
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<div class="w-full mt-4 p-10">
<button
type="button"
class="flex justify-start ml-2 rounded-md border px-3 py-2 bg-pink-600 text-white"
@click="addMore()"
>
Add More
</button>
<div v-for="(course, index) in courses" :key="index">
<div class="flex justify-start ml-2 mt-4">
<input
v-model="course.courseName"
class="w-full py-2 border border-indigo-500 rounded"
/>
<button
type="button"
class="ml-2 rounded-md border px-3 py-2 bg-red-600 text-white"
@click="remove(index)"
v-show="index != 0"
>
Remove
</button>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "HelloWorld",
props: {
msg: String,
},
data() {
return {
courses: [
{
courseName: "",
},
],
};
},
methods: {
addMore() {
this.courses.push({
courseName: "",
});
},
remove(index) {
this.courses.splice(index, 1);
},
},
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
Now add this component into App.vue file as below.
<template>
<div id="app">
<DynamicInput msg="Example of Dynamic Input" />
</div>
</template>
<script>
import DynamicInput from "./components/DynamicInput";
export default {
name: "App",
components: {
DynamicInput,
},
};
</script>
<style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
I have installed tailwind CSS to styling you have to install it.
If you like my post please follow me to get more blog posts.
.ltag__user__id__672647 .follow-action-button {
background-color: #9f0b46 !important;
color: #ffffff !important;
border-color: #9f0b46 !important;
}
Snehal Follow
Software Developer by Profession, mostly works in Laravel | Vue JS | Nuxt JS | PHP | Javascript | InertiaJS.
For more details you can refer below codesandbox.
Happy Reading. 🦄 ❤️
DEV Community
How to create dynamic input using Vue
Hello Readers, In this blog, I am going to show you, how we can create dynamic input using...
Tracing Squares to Detect
Hand Stability
https://ranashreyas.medium.com/tracing-squares-to-detect-hand-stability-e36faf70ca12?source=rss------vuejs-5
15th August, 2021Continue reading on Medium »
Hand Stability
https://ranashreyas.medium.com/tracing-squares-to-detect-hand-stability-e36faf70ca12?source=rss------vuejs-5
15th August, 2021Continue reading on Medium »
Plugins in Vue JS | How to create your own.
https://medium.com/@toakshay.official/plugins-in-vue-js-how-to-create-your-own-88f900b62f6d?source=rss------vuejs-5
So before starting let me tell you what plugins are in Vue JS and how can you benefit with them.Continue reading on Medium »
https://medium.com/@toakshay.official/plugins-in-vue-js-how-to-create-your-own-88f900b62f6d?source=rss------vuejs-5
So before starting let me tell you what plugins are in Vue JS and how can you benefit with them.Continue reading on Medium »
How to Add Chatbot in Vue.js Apps
https://medium.com/js-dojo/how-to-add-chatbot-in-vue-js-apps-d446e2111cbe?source=rss------vuejs-5
In this post, we will be learning how to add chatbot in Vue.js apps. Vue.js is an open-source JavaScript framework for building user…Continue reading on Vue.js Developers »
https://medium.com/js-dojo/how-to-add-chatbot-in-vue-js-apps-d446e2111cbe?source=rss------vuejs-5
In this post, we will be learning how to add chatbot in Vue.js apps. Vue.js is an open-source JavaScript framework for building user…Continue reading on Vue.js Developers »
VSCode:How to Clone the vue-upload-drop-image from Github and Run it
https://paulxiong.medium.com/vscode-how-to-clone-the-vue-upload-drop-image-from-github-and-run-it-3bf61d0b9b4e?source=rss------vuejs-5
https://github.com/paulxiong/vue-upload-drop-images.gitContinue reading on Medium »
https://paulxiong.medium.com/vscode-how-to-clone-the-vue-upload-drop-image-from-github-and-run-it-3bf61d0b9b4e?source=rss------vuejs-5
https://github.com/paulxiong/vue-upload-drop-images.gitContinue reading on Medium »
Options Api vs. Composition Api pada Vue.js
https://fhaladin-dev.medium.com/options-api-vs-composition-api-pada-vue-js-7df4dc8e9918?source=rss------vuejs-5
Composition api merupakan salah satu fitur baru yang hadir di vue.js 3 sebagai alternatif dari options api, composition api ini sendiri…Continue reading on Medium »
https://fhaladin-dev.medium.com/options-api-vs-composition-api-pada-vue-js-7df4dc8e9918?source=rss------vuejs-5
Composition api merupakan salah satu fitur baru yang hadir di vue.js 3 sebagai alternatif dari options api, composition api ini sendiri…Continue reading on Medium »
Build an Online Shop with Vue And Laravel Part 8.2 - Implement Vuex
https://alfianardhidev.medium.com/build-an-online-shop-with-vue-and-laravel-part-8-2-implement-vuex-dd71b9ff52a4?source=rss------vuejs-5
ImageContinue reading on Medium »
https://alfianardhidev.medium.com/build-an-online-shop-with-vue-and-laravel-part-8-2-implement-vuex-dd71b9ff52a4?source=rss------vuejs-5
ImageContinue reading on Medium »
Medium
Build an Online Shop with Vue And Laravel Part 8.2 - Implement Vuex
In this article, we will learn how to implement vuex as state management for this series of e-commerce applications with separate file…
Stop cross contamination in your Vue component — Part III
https://medium.com/@shashikantwagh721/stop-cross-contamination-in-your-vue-component-part-iii-17909e841a9?source=rss------vuejs-5
If you haven’t read Part I and Part II, I strongly recommend to check it out, so you will have context for this post.Continue reading on Medium »
https://medium.com/@shashikantwagh721/stop-cross-contamination-in-your-vue-component-part-iii-17909e841a9?source=rss------vuejs-5
If you haven’t read Part I and Part II, I strongly recommend to check it out, so you will have context for this post.Continue reading on Medium »
Medium
Stop cross contamination in your Vue component — Part III
If you haven’t read Part I and Part II, I strongly recommend to check it out, so you will have context for this post.