view.blade.php:
<div id="dashboard">
<calendar someattr="xxx"></calendar>
<calendar someattr="yyy"></calendar>
</div>
app.js:
import Calendar from './components/Calendar.vue';
new Vue({
el: '#dashboard',
components: {
Calendar
}
});
Calendar.vue:
<template>
... some code ...
</template>
<script>
export default {
props: ['someattr'],
methods: {
fetchEvents() {
//HERE
}
}
}
</script>
问题是:如何在方法fetchEvents中获取组件内的属性“someattr”?
答案 0 :(得分:1)
就像那样?
<template>
... some code ...
</template>
<script>
export default {
props: ['someattr'],
methods: {
fetchEvents() {
console.log(this.someattr)
}
}
}
</script>