mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 17:37:14 +00:00
b11e9c0e51
- [ ] babel-eslint https://github.com/babel/babel-eslint/issues/664 - [x] eslint-config-standard-jsx https://github.com/standard/eslint-config-standard-jsx/issues/32 - [x] eslint-config-standard to be stable release https://github.com/standard/eslint-config-standard/issues/123 - [x] eslint-plugin-html - [x] eslint-plugin-import - [x] eslint-plugin-jest - [x] eslint-plugin-node - [x] eslint-plugin-promise - [x] eslint-plugin-standard https://github.com/standard/eslint-plugin-standard/issues/29 - [x] eslint-plugin-vue https://github.com/vuejs/eslint-plugin-vue/pull/504 - [x] eslint-plugin-react https://github.com/yannickcr/eslint-plugin-react/releases/tag/v7.10.0
72 lines
1.6 KiB
Vue
Executable File
72 lines
1.6 KiB
Vue
Executable File
<template>
|
|
<div>
|
|
<h1>Nuxt Chat</h1>
|
|
<transition-group name="list" tag="ul">
|
|
<li v-for="(message, index) in messages" :key="index">
|
|
<component :is="message.component" :data="message.data" />
|
|
</li>
|
|
</transition-group>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import streamMessages from '@/js/messages.js'
|
|
// Dynamic components
|
|
const components = {
|
|
vText: () => import('@/components/text.vue' /* webpackChunkName: "components/text" */),
|
|
vImage: () => import('@/components/image.vue' /* webpackChunkName: "components/image" */),
|
|
vCode: () => import('@/components/code.vue' /* webpackChunkName: "components/code" */),
|
|
vChart: () => import('@/components/chart.js' /* webpackChunkName: "components/chart" */).then(m => m.default())
|
|
}
|
|
|
|
export default {
|
|
components,
|
|
data: () => ({
|
|
messages: []
|
|
}),
|
|
mounted() {
|
|
// Listen for incoming messages
|
|
streamMessages(async (message) => {
|
|
// Wait for the component to load before displaying it
|
|
await components[message.component]()
|
|
// Add the message to the list
|
|
this.messages.push(message)
|
|
})
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
h1 {
|
|
text-align: center;
|
|
font-family: Helvetica, Arial, sans-serif;
|
|
}
|
|
ul {
|
|
list-style: none;
|
|
margin: 0;
|
|
padding: 0;
|
|
width: 100%;
|
|
max-width: 300px;
|
|
margin: auto;
|
|
}
|
|
|
|
ul li {
|
|
display: block;
|
|
width: 100%;
|
|
border-radius: 20px;
|
|
margin-bottom: 5px;
|
|
font-family: Helvetica, Arial, sans-serif;
|
|
background: white;
|
|
border: 1px #ddd solid;
|
|
overflow: hidden;
|
|
opacity: 1;
|
|
}
|
|
.list-enter-active, .list-leave-active {
|
|
transition: all 0.4s;
|
|
}
|
|
.list-enter, .list-leave-to {
|
|
opacity: 0;
|
|
transform: translateY(20px);
|
|
}
|
|
</style>
|