{"id":186378,"date":"2023-06-15T08:20:07","date_gmt":"2023-06-15T00:20:07","guid":{"rendered":"http:\/\/www.idc.net\/help\/186378\/"},"modified":"2023-06-15T08:20:07","modified_gmt":"2023-06-15T00:20:07","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91%e7%99%be%e5%ba%a6%e5%b0%8f%e7%a8%8b%e5%ba%8f%e6%95%99%e7%a8%8b%ef%bc%9aswan-startdevicemotionlistening","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/186378\/","title":{"rendered":"\u540e\u6d6a\u4e91\u767e\u5ea6\u5c0f\u7a0b\u5e8f\u6559\u7a0b\uff1aswan.startDeviceMotionListening"},"content":{"rendered":"<ul>\n<li>swan.startDeviceMotionListening\n<ul>\n<li>\u65b9\u6cd5\u53c2\u6570\n<ul>\n<li>object \u53c2\u6570\u8bf4\u660e<\/li>\n<li>interval \u7684\u6709\u6548\u503c<\/li>\n<\/ul>\n<\/li>\n<li>\u793a\u4f8b\n<ul>\n<li>\u56fe\u7247\u793a\u4f8b<\/li>\n<li>\u4ee3\u7801\u793a\u4f8b\n<ul><\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h1><span><\/span>swan.startDeviceMotionListening<\/h1>\n<blockquote>\n<p>\u57fa\u7840\u5e93 3.30.2 \u5f00\u59cb\u652f\u6301\uff0c\u4f4e\u7248\u672c\u9700\u505a\u517c\u5bb9\u5904\u7406\u3002<\/p>\n<\/blockquote>\n<p><strong>\u89e3\u91ca<\/strong>\uff1a\u5f00\u59cb\u76d1\u542c\u8bbe\u5907\u65b9\u5411\u7684\u53d8\u5316\u3002<br \/><strong>Web \u6001\u8bf4\u660e<\/strong>\uff1a\u7531\u4e8e\u6d4f\u89c8\u5668\u5bf9\u4e8e W3C \u89c4\u8303\u7684\u5b9e\u73b0\u5dee\u5f02\uff0cstartDeviceMotionListening \u529f\u80fd\u5728\u90e8\u5206\u6d4f\u89c8\u5668(\u6bd4\u5982 Safari \u6d4f\u89c8\u5668)\u4e0b\u4e0d\u53ef\u7528\uff0c\u5728\u529f\u80fd\u4e0d\u53ef\u7528\u7684\u60c5\u51b5\u4e0b\u4f1a\u6267\u884c\u5f00\u53d1\u8005\u8bbe\u7f6e\u7684 fail \u56de\u8c03<\/p>\n<h2><span><\/span>\u65b9\u6cd5\u53c2\u6570<\/h2>\n<p>Object object<\/p>\n<h3><span><\/span>object \u53c2\u6570\u8bf4\u660e<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027\u540d<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u5fc5\u586b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<p>interval<\/p>\n<\/td>\n<td>\n<p>String<\/p>\n<\/td>\n<td>\n<p>\u5426<\/p>\n<\/td>\n<td>\n<p>normal<\/p>\n<\/td>\n<td>\n<p>\u76d1\u542c\u8bbe\u5907\u65b9\u5411\u7684\u53d8\u5316\u56de\u8c03\u51fd\u6570\u7684\u6267\u884c\u9891\u7387<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>success<\/p>\n<\/td>\n<td>\n<p>Function<\/p>\n<\/td>\n<td>\n<p>\u5426<\/p>\n<\/td>\n<td><\/td>\n<td>\n<p>\u63a5\u53e3\u8c03\u7528\u6210\u529f\u7684\u56de\u8c03\u51fd\u6570<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>fail<\/p>\n<\/td>\n<td>\n<p>Function<\/p>\n<\/td>\n<td>\n<p>\u5426<\/p>\n<\/td>\n<td><\/td>\n<td>\n<p>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\u7684\u56de\u8c03\u51fd\u6570<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>complete<\/p>\n<\/td>\n<td>\n<p>Function<\/p>\n<\/td>\n<td>\n<p>\u5426<\/p>\n<\/td>\n<td><\/td>\n<td>\n<p>\u63a5\u53e3\u8c03\u7528\u7ed3\u675f\u7684\u56de\u8c03\u51fd\u6570\uff08\u8c03\u7528\u6210\u529f\u3001\u5931\u8d25\u90fd\u4f1a\u6267\u884c\uff09<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span><\/span>interval \u7684\u6709\u6548\u503c<\/h3>\n<p>\u6839\u636e\u673a\u578b\u6027\u80fd\u3001\u5f53\u524d CPU \u4e0e\u5185\u5b58\u7684\u5360\u7528\u60c5\u51b5\uff0cinterval \u7684\u8bbe\u7f6e\u4e0e\u5b9e\u9645 swan.onAccelerometerChange() \u56de\u8c03\u51fd\u6570\u7684\u6267\u884c\u9891\u7387\u4f1a\u6709\u4e00\u4e9b\u51fa\u5165\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u503c<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<p>game<\/p>\n<\/td>\n<td>\n<p>\u9002\u7528\u4e8e\u66f4\u65b0\u6e38\u620f\u7684\u56de\u8c03\u9891\u7387\uff0c\u5728 20ms\/\u6b21 \u5de6\u53f3<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>ui<\/p>\n<\/td>\n<td>\n<p>\u9002\u7528\u4e8e\u66f4\u65b0 UI \u7684\u56de\u8c03\u9891\u7387\uff0c\u5728 60ms\/\u6b21 \u5de6\u53f3<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>normal<\/p>\n<\/td>\n<td>\n<p>\u666e\u901a\u7684\u56de\u8c03\u9891\u7387\uff0c\u5728 200ms\/\u6b21 \u5de6\u53f3<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span><\/span>\u793a\u4f8b<\/h2>\n<p>\u8df3\u8f6c\u7f16\u8f91\u5de5\u5177<\/p>\n<p>\u5728\u5f00\u53d1\u8005\u5de5\u5177\u4e2d\u6253\u5f00<\/p>\n<p>\u5728 WEB IDE \u4e2d\u6253\u5f00<\/p>\n<p>\u626b\u7801\u4f53\u9a8c<\/p>\n<p>\u4ee3\u7801\u793a\u4f8b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/static.sitestack.cn\/projects\/smartprogram-20210306\/97ebf63311ffac886baad1c970c1b97b.png\" class=\"aligncenter\"><\/p>\n<p>\u8bf7\u4f7f\u7528\u767e\u5ea6APP\u626b\u7801<\/p>\n<h3><span><\/span>\u56fe\u7247\u793a\u4f8b<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/static.sitestack.cn\/projects\/smartprogram-20210306\/a2879548c8af0e74b4197c8be040a3bf.gif\" class=\"aligncenter\"><\/p>\n<\/p>\n<h3><span><\/span>\u4ee3\u7801\u793a\u4f8b<\/h3>\n<ul>\n<li>SWAN<\/li>\n<li>JS<\/li>\n<\/ul>\n<pre>\n \n \n <ol>\n  \n  \n  <li><code><span>&lt;view<\/span><span> <\/span><span>class<\/span><span>=<\/span><span>\"wrap\"<\/span><span>&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>&lt;view<\/span><span> <\/span><span>class<\/span><span>=<\/span><span>\"card-area\"<\/span><span>&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>&lt;view<\/span><span> <\/span><span>class<\/span><span>=<\/span><span>\"list-area border-bottom\"<\/span><span> <\/span><span>s-for<\/span><span>=<\/span><span>\"item in infoList\"<\/span><span>&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>&lt;text<\/span><span> <\/span><span>class<\/span><span>=<\/span><span>\"list-item-key-4\"<\/span><span>&gt;<\/span><span>{{item.chineseName}}<\/span><span>&lt;\/text&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>&lt;text<\/span><span> <\/span><span>class<\/span><span>=<\/span><span>\"list-item-value\"<\/span><span>&gt;<\/span><span>{{item.value}}<\/span><span>&lt;\/text&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>&lt;\/view&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>&lt;view<\/span><span> <\/span><span>class<\/span><span>=<\/span><span>\"button-group\"<\/span><span>&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>&lt;button<\/span><span> <\/span><span>bind:tap<\/span><span>=<\/span><span>\"stopDeviceMotionListening\"<\/span><span> <\/span><span>disabled<\/span><span>=<\/span><span>\"{{!disabled}}\"<\/span><span> <\/span><span>type<\/span><span>=<\/span><span>\"primary\"<\/span><span> <\/span><span>hover-stop-propagation<\/span><span>=<\/span><span>\"true\"<\/span><span>&gt;<\/span><span>\u505c\u6b62\u76d1\u542c<\/span><span>&lt;\/button&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>&lt;button<\/span><span> <\/span><span>bind:tap<\/span><span>=<\/span><span>\"startDeviceMotionListening\"<\/span><span> <\/span><span>disabled<\/span><span>=<\/span><span>\"{{disabled}}\"<\/span><span> <\/span><span>type<\/span><span>=<\/span><span>\"primary\"<\/span><span> <\/span><span>hover-stop-propagation<\/span><span>=<\/span><span>\"true\"<\/span><span>&gt;<\/span><span>\u5f00\u59cb\u76d1\u542c<\/span><span>&lt;\/button&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>&lt;\/view&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>&lt;\/view&gt;<\/span><\/code><\/li>\n  \n  \n  <li><code><span>&lt;\/view&gt;<\/span><\/code><\/li>\n \n \n <\/ol><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>swan.startDeviceMotionListening \u65b9\u6cd5\u53c2\u6570 object \u53c2\u6570\u8bf4\u660e interv [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":186379,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182398],"tags":[],"class_list":["post-186378","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mini-program"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/186378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=186378"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/186378\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/186379"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=186378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=186378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=186378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}