VUE笔记深夜毒鸡汤
实现加载一个地址请求和跳转的同时动作
<script>
import CustomInput from './CustomInput.vue'
export default {
components: { CustomInput },
data() {
return {
url: 'https://www.baidu.com'
}
},
methods: {
load() {
url = this.url;
},
},
}
</script>
<template>
<CustomInput v-model="url" /> {{url}}
<a v-bind:href="url">SoSo</a>
</template>
<script>
export default {
props: ['modelValue'],
emits: ['update:modelValue']
}
</script>
<template>
<input
:value="modelValue"
@input="$emit('update:modelValue', $event.target.value)"
/>
<a @click="load"> {{url}} </a>
</template>
学之如大海汪洋,薄积厚发,后发制人,大学之道也。