You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/antdv-demo/docs/mentions/demo/prefix.md

882 B

#### 自定义触发字符 通过 prefix 属性自定义触发字符。默认为 @, 可以定义为数组。 #### Customize Trigger Token Customize Trigger Token by `prefix` props. Default to `@`, `Array` also supported.
<template>
  <a-mentions
    placeholder="input @ to mention people, # to mention tag"
    :prefix="['@', '#']"
    @search="onSearch"
  >
    <a-mentions-option v-for="value in MOCK_DATA[prefix] || []" :key="value" :value="value">
      {{ value }}
    </a-mentions-option>
  </a-mentions>
</template>
<script>
const MOCK_DATA = {
  '@': ['afc163', 'zombiej', 'yesmeck'],
  '#': ['1.0', '2.0', '3.0'],
};

export default {
  data() {
    return {
      prefix: '@',
      MOCK_DATA,
    };
  },
  methods: {
    onSearch(_, prefix) {
      console.log(_, prefix);
      this.prefix = prefix;
    },
  },
};
</script>