Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
JavaScriptExample
hello-uniapp
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
hello-uniapp
/
components
/
uLink.vue
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
59 lines (56 loc) · 1.77 KB
master
Breadcrumbs
hello-uniapp
/
components
/
uLink.vue
Copy path
Top
File metadata and controls
Code
Blame
59 lines (56 loc) · 1.77 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<
template
>
<
text
style
=
"
text-decoration
:
underline
"
:href
=
"
href
"
@click
=
"
openURL
"
:inWhiteList
=
"
inWhiteList
"
>{{text}}</
text
>
</
template
>
<
script
>
/**
*
@description
u-link是一个外部网页超链接组件,在小程序内打开内部web-view组件或复制url,在app内打开外部浏览器,在h5端打开新网页
*
@property
{String}
href
点击后打开的外部网页url,小程序中必须以https://开头
*
@property
{String}
text
显示的文字
*
@property
{Boolean}
inWhiteList
是否在小程序白名单中,如果在的话,在小程序端会直接打开内置web-view,否则会只会复制url,提示在外部打开
*
@example
*
<
u
-
link href
=
"
https://ext.dcloud.net.cn
"
text
=
"
https://ext.dcloud.net.cn
"
:
inWhiteList
=
"
true
"
><
/
u
-
link
>
*/
export
default
{
name
:
'
u-link
'
,
props
:
{
href
:
{
type
:
String
,
default
:
'
'
},
text
:
{
type
:
String
,
default
:
'
'
},
inWhiteList
:
{
type
:
Boolean
,
default
:
false
}
},
methods
:
{
openURL
() {
//
#ifdef APP-PLUS
plus
.
runtime
.
openURL
(
this
.
href
)
//
这里默认使用外部浏览器打开而不是内部web-view组件打开
//
#endif
//
#ifdef H5
window
.
open
(
this
.
href
)
//
#endif
//
#ifdef MP
if
(
this
.
inWhiteList
) {
//
如果在小程序的网址白名单中,会走内置webview打开,否则会复制网址提示在外部浏览器打开
uni
.
navigateTo
({
url
:
'
/pages/component/web-view/web-view?url=
'
+
this
.
href
});
}
else
{
uni
.
setClipboardData
({
data
:
this
.
href
});
uni
.
showModal
({
content
:
'
本网址无法直接在小程序内打开。已自动复制网址,请在手机浏览器里粘贴该网址
'
,
showCancel
:
false
});
}
//
#endif
}
}
}
</
script
>
<
style
>
</
style
>
You can’t perform that action at this time.