模块: win

窗口



all()

获取所有窗口

Returns:

窗体列表

Type:
Array
Example
$plus.win.all()


close(w [, closeOpts])

关闭窗体,注意:如果不能直接关闭主页

Parameters:
Name Type Argument Description
w string | window | WebviewObject

窗体对象或窗体id

closeOpts * <可选>

关闭参数

Properties
Name Type Argument Default Description
aniHide string <可选>
'none'|'auto'

关闭窗口的动画效果,非显示栈顶的窗口的默认值为'none'

duration number <可选>
300

关闭窗口动画的持续时间

Example
// 根据id关闭
$plus.win.close('login')


create(url [, id] [, opts])

创建新窗口

Parameters:
Name Type Argument Description
url string

新窗口加载的HTML页面地址

id string <可选>

新窗口的标识

opts object <可选>

参数

Properties
Name Type Argument Description
ext JSON <可选>

创建窗口的额外扩展参数,设置扩展参数后可以直接通过窗口对象的点(“.”)操作符获取扩展参数属性值。

style object <可选>

创建窗口的样式(如窗口宽、高、位置等信息),参考HTML5+ API

Returns:

窗体对象

Type:
window | WebviewObject
Example
$plus.win.create('login.html')


get(w)

获取窗体

Parameters:
Name Type Description
w string | window | WebviewObject

窗体对象或窗体id

Returns:

窗体对象

Type:
window | WebviewObject
Example
// 取得当前窗体
$plus.win.get()
// 获取id为‘login’的窗体
$plus.win.get('login')


getTop()

获取顶层窗口

Example
$plus.win.goHome()


goHome()

到首页

Returns:
Type:
Promise
Example
$plus.win.goHome().then((w)=>{
  // w为窗体对象
})


hide(w [, hideOpts])

隐藏窗体

Parameters:
Name Type Argument Description
w string | window | WebviewObject

窗体对象或窗体id

hideOpts object <可选>

隐藏参数

Properties
Name Type Argument Default Description
aniHide string <可选>
'none'|'auto'

隐藏窗口的动画效果,非显示栈顶的窗口的默认值为'none'

duration number <可选>
300

隐藏窗口动画的持续时间

Example
// 根据id隐藏
$plus.win.hide('login')


home()

获取home窗体

Returns:

窗体对象

Type:
window | WebviewObject
Example
$plus.win.home()


id(w)

获取窗体的id,兼容web和plus

Parameters:
Name Type Description
w string | window | WebviewObject

窗体对象或窗体id

Returns:

窗体对象

Type:
string
Example
$plus.win.id()


isHome(w)

是否主页

Parameters:
Name Type Description
w string | window | WebviewObject
Returns:

是不是主页

Type:
boolean
Example
// 当前窗体是否是主页
$plus.win.isHome()


isTop(w)

是否顶层窗口

Parameters:
Name Type Description
w String | window | WebviewObject
Returns:

是不是顶层窗口

Type:
Boolean
Example
// 当前窗体是否顶层窗口
$plus.win.isTop()


menu(url [, id] [, opts])

创建并打开侧滑窗口

Parameters:
Name Type Argument Description
url string

新窗口加载的HTML页面地址

id string <可选>

新窗口的标识

opts object <可选>

参数

Properties
Name Type Argument Default Description
loading boolean <可选>
false

是否显示loading等待效果

ani object <可选>

显示窗口的动画

Properties
Name Type Argument Default Description
aniShow string <可选>
'slide-in-right'

显示窗口的动画效果

duration number <可选>
300

显示窗口动画的持续时间

ext JSON <可选>

创建窗口的额外扩展参数,设置扩展参数后可以直接通过窗口对象的点(“.”)操作符获取扩展参数属性值。

style object <可选>

创建窗口的样式(如窗口宽、高、位置等信息),参考HTML5+ API

Returns:
Type:
Promise
Examples

左侧滑菜单

$plus.win.menu('index.html', "menuLeft", {
  ani: { aniShow: "slide-in-left" },
  style: {
    right: "30%",
    width: "70%",
    popGesture: "none"
  }
}).then(function(value) {
  // success
console.log('success')
}).catch( function(error) {
  // failure
console.log(error)
})

右侧滑菜单

$plus.win.menu('index.html', "menuRight", {
  ani: { aniShow: "slide-in-right" },
  style: {
    left: "30%",
    width: "70%",
    popGesture: "none"
  }
}).then(function(value) {
  // success
console.log('success')
}).catch( function(error) {
  // failure
console.log(error)
})

底侧滑菜单

$plus.win.menu('index.html', "menuBottom", {
  ani: { aniShow: "slide-in-bottom" },
  style: {
    height: "30%",
    top: "70%",
    popGesture: "none"
  }
}).then(function(value) {
  // success
console.log('success')
}).catch( function(error) {
  // failure
console.log(error)
})

顶侧滑菜单

$plus.win.menu('index.html', "menuTop", {
  ani: { aniShow: "slide-in-top" },
  style: {
    height: "30%",
    bottom: "70%",
    popGesture: "none"
  }
}).then(function(win) {
  // success
console.log('success')
}).catch( function(error) {
  // failure
console.log(error)
})


open(url [, id] [, opts])

创建并打开新窗口

Parameters:
Name Type Argument Description
url string

新窗口加载的HTML页面地址

id string <可选>

新窗口的标识

opts object <可选>

参数

Properties
Name Type Argument Default Description
loading boolean <可选>
false

是否显示loading等待效果

ani object <可选>

显示窗口的动画

Properties
Name Type Argument Default Description
aniShow string <可选>
'slide-in-right'

显示窗口的动画效果

duration number <可选>
300

显示窗口动画的持续时间

ext JSON <可选>

创建窗口的额外扩展参数,设置扩展参数后可以直接通过窗口对象的点(“.”)操作符获取扩展参数属性值。

style object <可选>

创建窗口的样式(如窗口宽、高、位置等信息),参考HTML5+ API

Returns:
Type:
Promise
Example
$plus.win.open('login.html', "login", {
  ext: {
    uid: 121
  }
}).then(function(win) {
  // success
console.log('success')
}).catch( function(error) {
  // failure
console.log(error)
})


openBrowser(url)

用浏览器打开url

Parameters:
Name Type Description
url String

页面地址

Example
$plus.win.openBrowser('http://www.baidu.com')


show(w [, opts])

显示窗体

Parameters:
Name Type Argument Description
w string | window | WebviewObject

窗体对象或窗体id

opts object <可选>

显示参数

Properties
Name Type Argument Default Description
loading boolean <可选>
false

是否显示loading等待效果

ani object <可选>

显示窗口的动画

Properties
Name Type Argument Default Description
aniShow string <可选>
'slide-in-right'

显示窗口的动画效果

duration number <可选>
300

显示窗口动画的持续时间

Returns:
Type:
Promise
Example
// 根据id显示
$plus.win.show('login').then(function(win) {
// success
  console.log('success')
}).catch( function(error) {
// failure
  console.log(error)
})