Vue.js - بحث Event Handling - آشنایی و شیوۀ استفاده از رویدادها - قسمت پنجم
نویسنده: امین دانش
تاریخ: ۱۳۹۶/۰۱/۲۴ ۲۲:۰
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
<html>
<head>
<meta charset="UTF-8">
<title>dotnet</title>
</head>
<body id="dotnettips">
<a v-on:click="message" href="bank.html">click here!</a>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.27/vue.min.js">
</script>
<script type="text/javascript">
new Vue({
el: '#dotnettips',
data:{
},
methods:{
message: function () {
alert("hi friends");
}
}
});
</script>
</body>
</html> new Vue({
el: '#dotnettips',
data:{
},
methods:{
message: function () {
alert("hi friends");
}
}
}); <html>
<head>
<meta charset="UTF-8">
<title>dotnet</title>
</head>
<body id="dotnettips">
<a v-on:click="message" href="bank.html">click here!</a>
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Vue.js گرفتن یک المنت در </title>
</head>
<body>
<div id="main">
<input type="text" name="fullName" id="fullName">
<button @click='getFullNameValue()'>Show Me</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
new Vue({
el: '#main',
data() {
return {
}
},
methods: {
getFullNameValue() {
let fullNameValue = document.querySelector('#fullName').value;
alert(fullNameValue);
}
}
});
</script>
</body>
</html> let fullNameValue = document.querySelector('#fullName') getFullNameValue() {
//let fullNameValue = document.querySelector('#fullName').value;
let fullNameValue = $('#fullName');
alert(fullNameValue.val());
} getFullNameValue() {
//let fullNameValue = document.querySelector('#fullName').value;
//let fullNameValue = $('#fullName').val();
let fullNameValue = this.$el.querySelector('#fullName');
alert(fullNameValue.value );
} <!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Vue.js گرفتن یک المنت در </title>
</head>
<body>
<div id="main">
<input type="text" name="fullName" id="fullName" ref="refFullName">
<button @click='getFullNameValue()'>Show Me</button>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
new Vue({
el: '#main',
data() {
return {
}
},
methods: {
getFullNameValue() {
//let fullNameValue = document.querySelector('#fullName').value;
//let fullNameValue = $('#fullName').val();
//let fullNameValue = this.$el.querySelector('#fullName').value;
let fullNameValue = this.$refs.refFullName;
alert(fullNameValue.value);
}
}
});
</script>
</body>
</html> getFullNameValue: function() {
...
} <button v-on:click='getFullNameValue()'>Show Me</button>