【问题标题】:How to remove everything before provided value如何在提供值之前删除所有内容
【发布时间】:2020-04-26 11:20:42
【问题描述】:

我正在使用 Bootstrap Vue 并希望使用格式化程序回调将 html 插入表内的列中。 Bootstrap 文档示例将链接格式化为锚链接 前任。 https://bootstrap-vue.js.org/docs/components/table/#shirley-partridge

    <b-table striped responsive hover :items="episodes" :fields="fields">
           <template v-slot:cell(version)="data">
        <a :href="`${data.value.replace(/[^a-z]+/i,'-').toLowerCase()}`">{{ data.value }}</a>
      </template>
    </b-table>

我从版本属性中提取了一个完整的 url,并且只想在模板中使用这个 url,如何使用格式化程序删除我的 url 之前的所有内容?

    this.episodes = response.map((item) => {
          return {
            category: item.fields.title,
            episode_name: item.fields.splash,
            episode_acronym: item.fields.description,
            version: 'https://myurl/webinars' + item.fields.slug + '/' +'test',

          }
        })

所需的链接是https://myurl/webinars....

【问题讨论】:

  • 您可以发布您尝试过的内容吗?首选 jsfiddle。
  • 你能显示你的&lt;b-table&gt;标记吗?

标签: regex vue.js bootstrap-vue


【解决方案1】:

我能够通过保持相对 url 格式并使用 - 而不是 + 符号更新格式化程序来实现此功能

        <a :href="`${data.value.replace(/[^a-z]-/i,'-').toLowerCase()}`">Definition</a>

【讨论】:

    猜你喜欢
    • 2022-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多