Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How vuejs creates and calls global methods

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces vuejs how to create and call global methods, the article is very detailed, has a certain reference value, interested friends must read it!

Create and call a global method: 1, customize a method under any file in the src directory of the vue project; 2, introduce a custom method using the importstatement in the "main.js" file, and mount the method on the vue instance; 3, in the required page, use the "$vue instance. Method name ()" statement to call the method.

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

Vue.js creates and calls global methods

In the vue project, first customize a method under any file in src, as an example

TransNum (num) {if (typeof (num) = 'undefined') {return 0} else {let oldNum = num.toString () .trim () let len = oldNum.length if (len

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report