官术网_书友最值得收藏!

  • Vue.js 2.x by Example
  • Mike Street
  • 110字
  • 2021-07-02 20:00:26

Creating links using v-html

The next step is to link the email address so that it is clickable for users viewing the list of people. In this instance, we need to concatenate strings by adding a mailto: before the email address. 

The first instinct is to do the following:

      <a href="mailto:{{person.email}}">{{ person.email }}</a>

But Vue doesn't allow interpolation inside attributes. Instead, we must use the v-bind directive on the href attribute. This turns the attribute into a JavaScript variable, so any raw text must be written in quotes, and the concatenated with the desired variable:

<a v-bind:href="'mailto:' + person.email">{{ person.email }}</a>

Note the addition of v-bind:, the single quotes and concatenation + identifier.

主站蜘蛛池模板: 莱阳市| 永靖县| 堆龙德庆县| 太康县| 福鼎市| 禄劝| 海口市| 四子王旗| 安宁市| 乾安县| 宜宾县| 仁布县| 新河县| 灌云县| 九江市| 安仁县| 西昌市| 景宁| 磐安县| 绥中县| 鄂托克旗| 时尚| 长寿区| 余干县| 潢川县| 华安县| 榆树市| 长武县| 兖州市| 巴塘县| 蕲春县| 靖宇县| 马龙县| 霍林郭勒市| 沧源| 太康县| 子洲县| 绿春县| 监利县| 武乡县| 黑水县|