npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vuepress-plugin-demo-container-v2.7

v2.8.0

Published

Vuepress plugin for demo block.

Readme

简介

Demo Container V2 是一个基于 Vuepress 的插件,它可以为你提供简单便利的组件示例编写体验。

它可以帮你做到:

  1. 使用自定义 ::: demo 语法,写一遍示例即可自动生成组件示例与代码示例;
  2. 支持示例中的 import 语法;

安装

使用 yarn:

yarn add vuepress-plugin-demo-container-v2 -D

或者 npm:

npm i vuepress-plugin-demo-container-v2 -D

使用

打开 .vuepress/config.js 文件, 添加插件:

module.exports = {
  plugins: ['demo-container-v2']
}

在 md 文件中可以按照以下格式书写代码示例:

传统语法

::: demo
```vue
<template>
  <div>
    <p>{{ message }}</p>
    <input v-model="message" placeholder="Input something..."/>
  </div>
</template>
<script>
  import { ref } from 'vue-demi'
  export default {
    setup () {
      const message = ref('Hello Here')

      return {
        message
      }
    }
  }
</script>
` ``
<!-- 忽略上一行的空格 -->
:::

Script Setup 语法 (Vue 2.7+)

现在插件已经完全支持 Vue 2.7+ 的 script-setup 语法,包括:

基本用法

::: demo
```vue
<template>
  <div>
    <p>{{ message }}</p>
    <input v-model="message" placeholder="Input something..."/>
  </div>
</template>
<script setup>
import { ref } from 'vue'

const message = ref('Hello Here with Script Setup!')
</script>
` ``
<!-- 忽略上一行的空格 -->
:::

高级用法

插件支持 script-setup 的所有特性,包括:

  • 响应式 API(ref, reactive, computed, watch, watchEffect)
  • 函数声明
  • defineProps 和 defineEmits
  • 复杂的导入语句
::: demo
```vue
<template>
  <div>
    <h1>{{ greeting }}</h1>
    <p>Counter: {{ count }}</p>
    <p>Doubled: {{ doubled }}</p>
    <button @click="increment">Increase</button>
    <button @click="decrement">Decrease</button>
  </div>
</template>
<script setup>
import { ref, computed, watch } from 'vue'

const count = ref(0)
const greeting = 'Hello, Advanced Script Setup!'

const doubled = computed(() => count.value * 2)

const increment = () => {
  count.value++
}

const decrement = () => {
  count.value--
}

// 监听 count 变化
watch(count, (newValue, oldValue) => {
  console.log(`Count changed from ${oldValue} to ${newValue}`)
})
</script>
<style scoped>
h1 {
  color: #42b983;
}
</style>
` ``
<!-- 忽略上一行的空格 -->
:::

使用 defineProps 和 defineEmits

::: demo
```vue
<template>
  <div>
    <h2>{{ title }}</h2>
    <p>Message: {{ message }}</p>
    <button @click="sendMessage">Send Message</button>
  </div>
</template>
<script setup>
import { ref } from 'vue'

const props = defineProps({
  title: {
    type: String,
    default: 'Default Title'
  },
  initialMessage: {
    type: String,
    default: 'Hello'
  }
})

const emit = defineEmits(['message-sent'])

const message = ref(props.initialMessage)

const sendMessage = () => {
  emit('message-sent', message.value)
}
</script>
<style scoped>
div {
  border: 1px solid #ddd;
  padding: 15px;
  border-radius: 5px;
}
</style>
` ``
<!-- 忽略上一行的空格 -->
:::

点此查看完整文档

致谢

该项目是受到 ElementUI / md-loader 的启发而生,向 饿了么大前端 致意。

贡献者

许可

MIT License @2020-PRESENT Wayco Wei