使用callback
代码中的选项:
_googWcmGet(function(formattedNumber, rawNumber) {
// put `formattedNumber` in the right elements.
// for example, to change a link:
[].forEach.call(document.getElementsByClassName('your class'),
function(el) {
el.href = 'tel:' + rawNumber;
el.textContent = el.innerText = formattedNumber;
// use the above line to make the link’s text be the phone number.
// If you don’t want that behavior, delete the line.
});
// and replace `your class` with the class you want.
}, 'your number', {
timeout: 1000, // optional; how long before giving up and
// never calling the above function
cache: false // optional; set to disable saving the number in a cookie.
});
请注意,您需要将其放在他们让您复制粘贴的代码之后。