Commit e43ec9e2 by 尹烁恒

测试支持多重组件嵌套

parent 7b05dd2c
...@@ -24,7 +24,8 @@ module.exports = { ...@@ -24,7 +24,8 @@ module.exports = {
// allow async-await // allow async-await
'generator-star-spacing': 0, 'generator-star-spacing': 0,
// allow debugger during development // allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'space-before-function-paren': 0
}, },
globals: { globals: {
App: true, App: true,
......
<template> <template>
<div> <div>
<div class="card"> <div class="card" :class="{'is-active': active}">
{{text}} {{text}}
<p class="card-item" v-for="(item, subindex) in list" :key="subindex" @tap.stop="handleTap(subindex)"> <optio :text="item" v-for="(item, index) in list" :key="index"></optio>
{{item.id + 'item.id'}}
</p>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import optio from '@/components/option-item'
export default { export default {
components: {
optio
},
props: ['text', 'list'], props: ['text', 'list'],
data() {
return {
active: true
}
},
methods: { methods: {
handleTap (index) { handleTap (index) {
console.log('card.vue', index) console.log('card.vue', index)
......
<template>
<div class="option-item">
{{text}}
</div>
</template>
<script>
export default {
props: {
text: {
type: String,
default: ''
}
},
methods: {
handleTap (index) {
console.log('card.vue', index)
}
}
}
</script>
<style>
</style>
<template> <template>
<div class="counter-warp"> <div class="counter-page">
<p>Vuex counter:{{ count }}</p> <scroll-view
<p>Vuex log: {{ log }}</p> class="scroll-left"
<p> scroll-y
<button @click="increment">+</button> :style="{'height': height + 'rpx'}"
<button @click="decrement">-</button> >
</p> <card v-for="(item, index) in List" :key="index" :text="item.name" :list="item.list"></card>
</scroll-view>
<a href="/pages/index/main" class="home">去往首页</a>
</div> </div>
</template> </template>
<script> <script>
// Use Vuex // Use Vuex
import card from '@/components/card'
import store from '@/store' import store from '@/store'
export default { export default {
...@@ -24,6 +24,18 @@ export default { ...@@ -24,6 +24,18 @@ export default {
return store.state.logPage.log return store.state.logPage.log
} }
}, },
components: {
card
},
data() {
return {
height: 400,
List: [{
name: '小米',
list: ['小米1', '小米2', '小米3']
}]
}
},
methods: { methods: {
increment () { increment () {
store.commit('increment') store.commit('increment')
...@@ -36,15 +48,16 @@ export default { ...@@ -36,15 +48,16 @@ export default {
</script> </script>
<style> <style>
.counter-warp { .counter-page {
text-align: center; width: 100%;
margin-top: 100px; background: #fff;
height: 100vh;
} }
.home { .scroll-left {
display: inline-block; width: 300rpx;
margin: 100px auto; height: 100vh;
padding: 5px 10px; background: red;
color: blue; color: white;
border: 1px solid blue;
} }
</style> </style>
<template> <template>
<div class="index-page"> <div class="index-page">
<button class="start-button" @click="handleStart">开始</button>
</div> </div>
</template> </template>
...@@ -22,10 +22,14 @@ export default { ...@@ -22,10 +22,14 @@ export default {
}, },
components: { components: {
card
}, },
methods: { methods: {
handleStart() {
wx.navigateTo({
url: '/pages/counter/main'
})
},
getUserInfo () { getUserInfo () {
wx.login({ wx.login({
success: () => { success: () => {
...@@ -49,5 +53,8 @@ export default { ...@@ -49,5 +53,8 @@ export default {
<style scoped lang="scss"> <style scoped lang="scss">
.index-page { .index-page {
@include ellipsis; @include ellipsis;
width: 100%;
height: 100vh;
background: #fff;
} }
</style> </style>
...@@ -7,6 +7,7 @@ app.$mount() ...@@ -7,6 +7,7 @@ app.$mount()
// 这里才会导出json // 这里才会导出json
export default { export default {
config: { config: {
navigationBarTitleText: '布里吉' navigationBarTitleText: '布里吉',
disableScroll: true
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment