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

  • 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.

主站蜘蛛池模板: 大庆市| 五原县| 且末县| 闵行区| 右玉县| 金堂县| 平阳县| 定边县| 深圳市| 通州区| 海盐县| 万州区| 峨边| 万安县| 仲巴县| 南通市| 平利县| 且末县| 柏乡县| 福建省| 汝阳县| 德江县| 陇西县| 九龙城区| 溧水县| 黔南| 西贡区| 昌黎县| 新野县| 宜州市| 温泉县| 藁城市| 灵寿县| 乌苏市| 康定县| 昌江| 伊宁市| 莎车县| 云龙县| 屏山县| 安西县|