Nhảy tới nội dung

Bắt đầu hỗ trợ ở phiên bản:

  • SDK: 2.11.0
Lưu ý

Cần xin cấp quyền tại trang Quản lý ứng dụng

Mở Webview. Lắng nghe sự kiện WebviewClosed ở app cần biết khi nào webview được đóng.

Parameters​

Object object​

PropertyTypeDefaultRequiredDescriptionMinimum Version
urlstringyes
configobjectCấu hình cho webview2.30.0
successfunctionCallback function khi gọi api thành công
failfunctionCallback function khi gọi api thất bại

Object config​

PropertyTypeDefaultRequiredDescriptionMinimum Version
stylestringbottomSheetKiểu hiển thị cho webview:
  • 'bottomSheet': Cửa sổ hiển thị từ dưới đáy của màn hình
  • 'normal': Cửa sổ hiển thị toàn màn hình
leftButtonstringbackNút bên trái thanh header: (chỉ hỗ trợ cho style 'bottomSheet')
  • 'back': Nút quay về trang trước
  • 'none': không hiển thị nút

Sample Code​

import { openWebview } from "zmp-sdk/apis";

openWebview({
url: "https://mini.zalo.me/",
config: {
style: "bottomSheet",
leftButton: "back"
},
success: (res) => {
// xử lý khi gọi api thành công
},
fail: (error) => {
// xử lý khi gọi api thất bại
console.log(error);
}
});

Hoặc

import { openWebview } from "zmp-sdk/apis";

const openUrlInWebview = async () => {
try {
await openWebview({
url: "https://mini.zalo.me/",
config: {
style: "bottomSheet",
leftButton: "back"
}
});
} catch (error) {
// xử lý khi gọi api thất bại
console.log(error);
}
};