Javascript 角度材质类型错误:$mdThemingProvider.backgroundPalette不是函数
我正在使用md选项卡,希望将背景颜色从默认的浅灰色设置为白色。在我的模块中,我定义了以下内容:Javascript 角度材质类型错误:$mdThemingProvider.backgroundPalette不是函数,javascript,angularjs,angular-material,Javascript,Angularjs,Angular Material,我正在使用md选项卡,希望将背景颜色从默认的浅灰色设置为白色。在我的模块中,我定义了以下内容: var module = angular.module('myMod', ['ngMaterial']); module.config(function ($mdThemingProvider) { $mdThemingProvider.backgroundPalette('white'); }); 启动应用程序时,出现以下错误: Uncaught Error: [$injector:mod
var module = angular.module('myMod', ['ngMaterial']);
module.config(function ($mdThemingProvider) {
$mdThemingProvider.backgroundPalette('white');
});
启动应用程序时,出现以下错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module myMod due to:
TypeError: $mdThemingProvider.backgroundPalette is not a function
我使用的是1.1.5版的角材质
你知道为什么会发生这种错误吗?Thanx提前。您必须首先从提供商处获取要修改的主题:
$mdThemingProvider.theme('default')
.backgroundPalette('white');
我明白了。在模块中,必须为所有阴影定义白色:
var module = angular.module('myMod', ['ngMaterial']);
module
.config(function ($mdThemingProvider) {
$mdThemingProvider.definePalette('white', {
'50': 'ffffff',
'100': 'ffffff',
'200': 'ffffff',
'300': 'ffffff',
'400': 'ffffff',
'500': 'ffffff',
'600': 'ffffff',
'700': 'ffffff',
'800': 'ffffff',
'900': 'ffffff',
'A100': 'ffffff',
'A200': 'ffffff',
'A400': 'ffffff',
'A700': 'ffffff'
});
$mdThemingProvider
.theme('default')
.backgroundPalette('white');
});
并且必须在元素的相应html中设置颜色。就我而言:
<md-content md-colors="{'background-color': 'white'}">...</md-content>
我也试过了,但后来我得到了错误uncaughttypeerror:无法读取未定义的属性'600'。显然,我必须先定义白色。可能是吗?似乎白色不是预先定义的颜色之一,因此它似乎有可能包含您想要的信息