Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过JavaScript使用计算变量更改CSS属性的值_Javascript_Html_Css_Variables_Properties - Fatal编程技术网

通过JavaScript使用计算变量更改CSS属性的值

通过JavaScript使用计算变量更改CSS属性的值,javascript,html,css,variables,properties,Javascript,Html,Css,Variables,Properties,我试图用一个计算的变量值设置css属性的值 我有两个类.v-table\uu overflow和.v-datatable\uu actions。我想获取.v-table\uuuu overflow的宽度值,并在.v-datatable\uuu actions中设置该值作为此类的宽度值 我得到了这个错误: 未捕获的TypeError:无法读取未定义的属性“setProperty” 这样试试 var dtoverflow = document.querySelector('.v-table__ove

我试图用一个计算的变量值设置css属性的值

我有两个类
.v-table\uu overflow
.v-datatable\uu actions
。我想获取
.v-table\uuuu overflow
的宽度值,并在
.v-datatable\uuu actions
中设置该值作为此类的宽度值

我得到了这个错误:

未捕获的TypeError:无法读取未定义的属性“setProperty”

这样试试

var dtoverflow = document.querySelector('.v-table__overflow')
var dtoverflowWidth = getComputedStyle(dtoverflow).width;

var dtActions = document.querySelector('.v-datatable__actions') 
var dtActionsWidth = getComputedStyle(dtActions).width;

dtActions.style.width = dtoverflowWidth;

您在引发错误的最后一行中使用了
dtActionsWidth
而不是
dtActions

看起来
dtActionsWidth
dtActions
计算样式中的
宽度值。变量
dtActionsWidth
没有。也许你想要
dtActions.style.setProperty(…)
?这是一个VueTify应用程序-使用vue.js框架frontend@showdev该代码在引发错误的最后一行中使用了
dtActionsWidth
而不是
dtActions
var dtoverflow = document.querySelector('.v-table__overflow')
var dtoverflowWidth = getComputedStyle(dtoverflow).width;

var dtActions = document.querySelector('.v-datatable__actions') 
var dtActionsWidth = getComputedStyle(dtActions).width;

dtActions.style.width = dtoverflowWidth;