我正在使用网络蓝牙 API 来连接 BLE 设备。它在https://localhost上完美运行。但是当我在我的实时服务器上尝试它也是在 https 上或者当我在http://locahost上尝试时,它通过我这个错误“Origin is not allowed to access the service。提示:将服务 UUID 添加到 'optionalServices ' 在 requestDevice() 选项中。”。代码如下。我已经添加了 optionalServices。
scanDevices () {
if(navigator.bluetooth) {
navigator.bluetooth.requestDevice({
acceptAllDevices: true,
optionalService: ['0000fee0-0000-1000-8000-00805f9b34fb', '0000fee1-0000-1000-8000-00805f9b34fb']
})
.then(device => {
// save the device returned so you can disconnect later:
this.device = device;
this.device.addEventListener('gattserverdisconnected', this.onDisconnected);
// connect to the device once you find it:
return this.connect();
})
.then((server) => {
this.server = server;
return server;
})
.catch(function(error) {
// …Run Code Online (Sandbox Code Playgroud) 我正在使用drupal 8,我有一个实体,我想在实体表单中添加一个隐藏的类型字段。如何添加隐藏字段类型?像下面
<form>
<input type='hidden' name='my_hidden' />
</form>
Run Code Online (Sandbox Code Playgroud)
代码生成形式如下:
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('ID'))
->setDescription(t('The ID of the Timeslot entity.'))
->setReadOnly(TRUE);
return $fields;
}
Run Code Online (Sandbox Code Playgroud)