Todos los productos
Search
Centro de documentos

Mobile Platform as a Service:Establecer el color de la barra de navegación

Última actualización: Sep 05, 2026

Esta API establece el color de la barra de título.

Cómo usar la API setTitleColor

AlipayJSBridge.call("setTitleColor", {
  color: 16775138,
  reset: false // Optional. Specifies whether to reset the title color to the default. Default: false.
});
Nota

Para usar la API setTitleColor, establezca el parámetro H5Param.LONG_TRANSPARENT_TITLE en always o auto antes de que se cargue la página. Por ejemplo: param.putString(H5Param.LONG_TRANSPARENT_TITLE,"auto");

Ejemplo de código

<div style="padding-top:80px;">
  <a href="javascript:void(0)" class="btn title">Set navigation bar background color</a>
  <a href="javascript:void(0)" class="btn reset">Reset navigation bar background color</a>
  <a href="javascript:void(0)" class="btn pushWindow">Open a new window with a transparent navigation bar</a>
  <a href="javascript:void(0)" class="btn resetTransparent">Reset to a transparent navigation bar</a>
</div>

<script>
function ready(callback) {
  // If jsbridge is already injected, call it directly.
  if (window.AlipayJSBridge) {
    callback && callback();
  } else {
    // If not, listen for the injection event.
    document.addEventListener('AlipayJSBridgeReady', callback, false);
  }
}
ready(function(){
  document.querySelector('.title').addEventListener('click', function() {
    AlipayJSBridge.call("setTitleColor", {
      color: parseInt('108ee9', 16),
      reset: false // Optional. Specifies whether to reset the title color to the default. Default: false.
    });
  });

  document.querySelector('.reset').addEventListener('click', function() {
    AlipayJSBridge.call("setTitleColor",{
      color: 16775138,
      reset: true
    });
  });

  document.querySelector('.pushWindow').addEventListener('click', function() {
    AlipayJSBridge.call("pushWindow", {
      url: location.pathname + '?__webview_options__=transparentTitle%3Dalways'
    });
  });

  document.querySelector('.resetTransparent').addEventListener('click', function() {
    AlipayJSBridge.call("setTitleColor", {
      color: 16775138,
      resetTransparent: true
    });
  });
});
</script>

Referencia de la API

AlipayJSBridge.call('setTitleColor', {
  color: 16775138,
  reset: false,
  resetTransparent: false
}, fn)

Parámetros de entrada

Propiedad

Tipo

Descripción

Obligatorio

Valor predeterminado

color

int

Valor del color en formato decimal.

Sí

-