guide/repl/frontend/ #364
Unanswered
Replies: 3 comments 6 replies
-
作者,您好,请问怎么在这个主题内使用自定义vue组件呢? <template>
<div>
<h1>{{ title }}</h1>
<p>{{ content }}</p>
</div>
</template>
<script>
import axios from 'axios';
export default {
data() {
return {
title: 'API Data',
content: 'Loading...',
};
},
async created() {
try {
const response = await axios.get('http://localhost:8000/api/demo/');
this.content = response.data.data; // 假设 API 返回的数据中有一个 'content' 字段
} catch (error) {
console.error('Error fetching data:', error);
this.content = 'Failed to load data.';
}
},
};
</script>
<style>
/* Add your styles here */
</style>
然后我在markdown页面:
没有作用,我的部分配置: theme: plumeTheme({
plugins: {
shiki: {
languages: ['javascript', 'typescript', 'vue', 'bash', 'sh'],
},
markdownPower: {
bilibili: true,
},
markdownEnhance: {
echarts: true,
flowchart: true,
demo: true,
},
}
}), 您能够回答吗?谢谢! |
Beta Was this translation helpful? Give feedback.
2 replies
-
能不能把容器写法的title和desc做成solt。这样可以有更丰富样式 优化为以下写法:三者顺序可以调整,标题可以靠左靠中靠右 ::: code-title top/center/bottom left/center/right
:::
::: code-desc top/center/bottom
:::
::: code-tabs top/center/bottom
::: |
Beta Was this translation helpful? Give feedback.
2 replies
-
作者,您好,请问如何在vue组件演示中的容器语法中添加组件的嵌套呢? @tab App.vue <script setup>
import { ref } from 'vue'
import TodoItem from './TodoItem.vue'
const newTodoText = ref('')
const todos = ref([
{
id: 1,
title: 'Do the dishes'
},
{
id: 2,
title: 'Take out the trash'
},
{
id: 3,
title: 'Mow the lawn'
}
])
let nextTodoId = 4
function addNewTodo() {
todos.value.push({
id: nextTodoId++,
title: newTodoText.value
})
newTodoText.value = ''
}
</script>
<template>
<form v-on:submit.prevent="addNewTodo">
<label for="new-todo">Add a todo</label>
<input
v-model="newTodoText"
id="new-todo"
placeholder="E.g. Feed the cat"
/>
<button>Add</button>
</form>
<ul>
<todo-item
v-for="(todo, index) in todos"
:key="todo.id"
:title="todo.title"
@remove="todos.splice(index, 1)"
></todo-item>
</ul>
</template> @tab TodoItem.vue <script setup>
defineProps(['title'])
defineEmits(['remove'])
</script>
<template>
<li>
{{ title }}
<button @click="$emit('remove')">Remove</button>
</li>
</template> ::: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
guide/repl/frontend/
概述 前端代码演示 由 vuepress-plugin-md-enhance 提供支持。 前端 代码演示 默认不启用,你可以通过配置来启用它。 语法 提示 JSON 块是可选的,可用的配置详见配置 插件支持三种类型 normal(默认) vue react 可用的语言 你可以在演示块中使用不同语言。 当你设置一些不能在浏览器上直接运行的语言时,由于插件...
https://theme-plume.vuejs.press/guide/repl/frontend/
Beta Was this translation helpful? Give feedback.
All reactions