@EncyKe
2016-10-26T02:53:23.000000Z
字数 1049
阅读 1641
#手记
<script>
// 传入子组件名称及其引用路径(Pre 表可能的前缀);
import PreAB from '../aB.vue';
module.exports = {
data() {
return {
// 在数据中添加驼峰命名的前端接口;
aB: '';
}
}
components: {
// 在组件中引入子组件名称;
PreAB,
},
methods: {
// 在方法中同步前后端接口(如若需要);
someIO.someMethod({
a_b: this.aB,
})
}
}
</script>
<pre-a-b
:a-b.sync="aB">
</pre-a-b>
<style scoped lang="sass">
/* scoped表本组件私有 */
</style>
<script>
module.exports = {
// 定义组件名称;
name: 'AB',
props: {
// 定义前端接口,驼峰命名;
aB: {
type: String
}
},
methods: {
handleSth: function() {
}
}
};
</script>
<template>
<div
v-model="aB"
@click="handleSth">
</div>
</template>
<a-b
:a="a">
<!-- 传入前端自定义字段 -->
</a-b>
props: {
a: {
type: Object,
}
},
<script>
module.exports = {
methods: {
handleSth() {
someIO.someMethod ({
// 执行代码;
}).then(() => {
// 输入后续;
}).catch(err => {
// 报错处理;
});
}
}
}
</script>