小编mka*_*man的帖子

date.toLocaleDateString(locale,{timeZone:'Asia/Kolkata'})不在ie 11中工作

我试图用时区和语言环境转换日期和时间,但它在IE11中不起作用.它适用于chrome,firefox和edge.

最简单完整的可验证示例:

function getLocalTime(date){
    var timeZone = "Asia/Kolkata";
    var utcDate =  new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
    var dateAndTime = utcDate.toLocaleDateString("en",{timeZone:timeZone})+" "+ utcDate.toLocaleTimeString("en",{timeZone:timeZone}).replace(/:\d+ /, ' ');;
    return dateAndTime;
}

console.log(getLocalTime(Date());
Run Code Online (Sandbox Code Playgroud)

IE11中的错误:

SCRIPT5118: Option value 'ASIA/KOLKATA' for 'timeZone' is outside of valid range. Expected: ['UTC']

注意:我不想使用任何第三方js.

javascript internet-explorer

12
推荐指数
1
解决办法
5266
查看次数

如何使用threejs创建轴测斜/骑士/橱柜?

我找到了有关如何使用 THREE.js等距相机中创建(轴测)等距相机的示例,但是如何创建轴测斜线?

three.js axonometric

7
推荐指数
1
解决办法
830
查看次数

如果 CSS 省略号在 React 组件中处于活动状态,如何有条件地显示标题工具提示

问题

我正在寻找一种干净的方法来在应用了 CSS 省略号的项目上显示标题工具提示。(在 React 组件内)

我尝试过的:

我设置了一个 ref,但直到 componentDidUpdate 之前它才存在,因此在 componentDidUpdate 中我强制更新。(这需要更多的返工来处理 prop 更改等,我可能会使用 setState 来代替。)这种方法可行,但有很多我认为不可接受的警告。

  1. setState/forceUpdate - 也许这是一个必要的邪恶
  2. 如果浏览器尺寸改变怎么办?每次调整大小都需要重新渲染吗?我想我也需要对此进行反跳。恶心。

问题:

有没有更优雅的方式来实现这个目标?

半功能MCVE:

https://codepen.io/anon/pen/mjYzMM

class App extends React.Component {
  render() {
    return (
      <div>
        <Test message="Overflow Ellipsis" />
        <Test message="Fits" />
      </div>
    );
  }
}

class Test extends React.Component {
  constructor(props) {
    super(props);
    this.element = React.createRef();
  }
  componentDidMount() {
    this.forceUpdate();
  }

  doesTextFit = () => {
    if (!this.element) return false;
    if (!this.element.current) return false;
    console.log(
      "***",
      "offsetWidth: ", …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

7
推荐指数
1
解决办法
5782
查看次数

THREE.JS Uncaught ReferenceError:OrbitControls 未定义

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const controls = new OrbitControls(camera);
camera.position.set(200, 0, 0);
controls.update();

const geometry = new THREE.SphereGeometry(50, 32, 32);
const material = new THREE.MeshBasicMaterial({
  color: 0xffff00
});
const sphere = new THREE.Mesh(geometry, material);
scene.add(sphere);


const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

function animate() {

  requestAnimationFrame(animate);

  controls.update();

  renderer.render(scene, camera);

}
Run Code Online (Sandbox Code Playgroud)
<script src="https://cdn.jsdelivr.net/npm/three@0.129.0/build/three.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

当我运行我的 javascript 代码时。我收到以下错误“Uncaught ReferenceError:OrbitControls 未定义”。我看过这篇文章,但似乎没有帮助。有任何想法吗?

我的 OrbitControls.js 位于 Three.js 文件下的同一文件中

javascript three.js

6
推荐指数
1
解决办法
6070
查看次数

PHP搜索数组在数组中

我有这样的数组结果:

Array
(
    [0] => stdClass Object
        (
            [id_global_info] => 78
            [name] => rfhd
            [body] => dhfdhdf
            [contact_author] => mirko
            [date_created] => 2012-03-15 16:11:54
            [date_expires] => 2012-04-14 16:11:54
            [email] => 
            [location_id] => 1
            [category_id] => 26
            [tag] => fhdhfdhfd
            [info_type_id] => 4
            [user_id] => 3
        )

    [1] => stdClass Object
        (
            [id_global_info] => 79
            [name] => rfhd
            [body] => dhfdhdf
            [contact_author] => mirko
            [date_created] => 2012-03-15 16:11:56
            [date_expires] => 2012-04-14 16:11:56
            [email] => 
            [location_id] => 1
            [category_id] => 26
            [tag] …
Run Code Online (Sandbox Code Playgroud)

php

5
推荐指数
2
解决办法
3万
查看次数

phpcbf 抱怨缺少 CodeSniffer

问题

phpcbf 抱怨缺少 CodeSniffer,但它似乎在自己的 phar 中丢失了。

我的设置

Ubuntu 14.04 使用 ondrej ppa for PHP 5.6

这是我尝试安装的内容和验证安装的输出

  • sudo pear install PHP_CodeSniffer

    pear list=> PHP_CodeSniffer 2.6.0 稳定版

  • curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar

    php phpcbf.phar --version=> Squiz 的 PHP_CodeSniffer 版本 2.6.0(稳定)(http://www.squiz.net

我如何运行 phpcbf

php phpcbf.phar --standard=PSR2 ./MyDir/MyClass.php

PHP Warning: chdir(): No such file or directory (errno 2) in phar:///home/myuser/projects/myproject/src/phpcbf.phar/CodeSniffer.php on line 861

更新:尽管有警告,但它似乎工作正常。

php phar phpcs

5
推荐指数
1
解决办法
1706
查看次数

svn到git转换:正确的远程引用必须以'refs /'错误开头

(我发布这个问题的目的是为了自己回答这个问题,因为我在其他地方找不到答案.希望它能帮助遇到同样问题的其他人,下次我试图这样做时会帮助我.)

挑战

我想将SVN存储库转换为本地托管的gitlab GIT存储库并维护历史记录.

安装程序

Gitlab 8.5,Ubuntu 14.04 LTS,颠覆1.8.8

问题

使用git-svn或svn2git从svn转换为git的初始尝试导致以下错误.

错误

svn-remote.svn: remote ref '//example.com:81/svn/myrepository/trunk:refs/remotes/trunk' must start with 'refs/'

我试过的

我在下面的外部参考资料中都遵循了两个指南.

使用外部参考

svn git git-svn gitlab svn2git

4
推荐指数
2
解决办法
3479
查看次数

如何对嵌套的无序列表使用破折号?

问题:我想将所有嵌套的无序列表切换为破折号而不是子弹.

我相信选择这些嵌套列表项的XPath表达式是:// ul/li/ul // li

我相信这是适合修改的模板:

<xsl:template match="*[contains(@class, ' topic/ul ')]/*[contains(@class, ' topic/li ')]">
    <fo:list-item xsl:use-attribute-sets="ul.li">
        <fo:list-item-label xsl:use-attribute-sets="ul.li__label">
            <fo:block xsl:use-attribute-sets="ul.li__label__content">
                <fo:inline>
                    <xsl:call-template name="commonattributes"/>
                </fo:inline>
                <xsl:call-template name="insertVariable">
                    <xsl:with-param name="theVariableID" select="'Unordered List bullet'"/>
                </xsl:call-template>
            </fo:block>
        </fo:list-item-label>

        <fo:list-item-body xsl:use-attribute-sets="ul.li__body">
            <fo:block xsl:use-attribute-sets="ul.li__content">
                <xsl:apply-templates/>
            </fo:block>
        </fo:list-item-body>

    </fo:list-item>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

它引用了名为"Unordered List Bullet"的en.xml中的变量:

<variable id="Unordered List bullet">&#x2022;</variable>
Run Code Online (Sandbox Code Playgroud)

我已经尝试将该变量调用包装为引用另一个变量"Unordered List Dash"(如果它是嵌套的).我还是有点挂了.什么是最优雅的方法?我应该为这些嵌套项目设置一个额外的模板吗?

我正在使用DITA-OT 1.5.4.

dita dita-ot

1
推荐指数
1
解决办法
759
查看次数

谁能解释这个警告?

警告的含义是什么?

Warning: preg_replace() [function.preg-replace]: Compilation failed: PCRE does not support \L, \l, \N{name}, \U, or \u at offset 1 in
Run Code Online (Sandbox Code Playgroud)

它由这个函数触发:

file_put_contents($file,preg_replace('(\uid=\d+)', 'uid=' . $uid, file_get_contents($file)));
Run Code Online (Sandbox Code Playgroud)

即这种模式:

'(\uid=\d+)'
Run Code Online (Sandbox Code Playgroud)

它在本地工作,但不在线,这意味着它可能是我主机的PHP版本.我试图google一个解决方法,但找不到任何东西.

php

1
推荐指数
1
解决办法
141
查看次数

样式表无法识别空篇章

DITA-OT:1.7.3

问题:我的自定义样式表中的空章节出错:

"fo:block-container" is missing child elements. Required content model: marker* (%block;)+

默认的PDF2样式呈现正常.

在章节中添加主题会使其消失.该错误只给出了topic.fo的最后一行,其中列为0.

这是页面序列(缩进),错误所在的行在id ="d2e394"之前开始:

<fo:page-sequence
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    force-page-count="no-force"
    initial-page-number="1"
    master-reference="body-sequence">
    <fo:static-content
        flow-name="xsl-footnote-separator">
        <fo:block>
            <fo:leader
                color="black"
                leader-length="25%"
                leader-pattern="rule"
                rule-style="solid"
                rule-thickness="0.5pt"/>
        </fo:block>
    </fo:static-content>
    <fo:static-content
        flow-name="odd-body-footer">
        <fo:table
            font-size="8pt"
            space-after="0.5in"
            space-after.conditionality="retain"
            text-align="end"
            line-height-shift-adjustment="disregard-shifts"
            font-family="Helvetica, Arial Unicode MS">
            <fo:table-column
                column-width="40%"/>
            <fo:table-column
                column-width="20%"/>
            <fo:table-column
                column-width="40%"/>
            <fo:table-body>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block
                            margin-left=".93in"
                            text-align="left">PN: XXXXXX</fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block
                            text-align="center">
                            <fo:retrieve-marker
                                retrieve-class-name="current-chapter-number"/>-<fo:page-number/>
                        </fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block
                            margin-right="0.74in"
                            text-align="right">
                            <fo:retrieve-marker
                                retrieve-class-name="current-document-header"/>
                        </fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-body>
        </fo:table>
    </fo:static-content>
    <fo:static-content
        flow-name="even-body-footer">
        <fo:table …
Run Code Online (Sandbox Code Playgroud)

dita

1
推荐指数
1
解决办法
1208
查看次数

Laravel访问在本地主机xampp上被禁止

我刚开始就陷入困境。我已经安装了laravel,当我运行php artisan serv命令时,会出现此(Laravel开发服务器在http:// localhost:8000 /上启动)行,但是当我通过浏览器(http:// localhost:8000 /)访问它时显示以下错误。

禁止访问!您无权访问所请求的对象。服务器对其进行了读保护或不可读。如果您认为这是服务器错误,请与网站管理员联系。错误403本地主机Apache / 2.4.18(Win32)OpenSSL / 1.0.2e PHP / 7.0.2

请帮帮我。任何帮助将不胜感激。我是Laravel的初学者。

apache xampp laravel artisan

1
推荐指数
1
解决办法
6947
查看次数

使输入类型时间为24格式jq

我正在尝试制作一些行,但是24格式而不是12格式所以当我点击向上调用inc()函数时调用输入字段2向上和向下调用dec()函数调用但是我的问题是这些功能inc和dec小时我怎样才能制作能够持续数小时和分钟的东西.

function inc() {
  var admissionTime = $(".add-time").val();
  var hours = parseInt(admissionTime.split(":")[0]); ///before
  var minutes = parseInt(admissionTime.split(":")[1]);
  hours = hours + 1;

  if (hours <= 24) {
    var bb = hours + ':' + minutes;
    $(".add-time").val(bb);
  } else {
    var bb = 00 + ':' + 00;
    $(".add-time").val(bb);
  }
}

function dec() {
  var admissionTime = $(".add-time").val();
  var hours = parseInt(admissionTime.split(":")[0]); ///before
  var minutes = parseInt(admissionTime.split(":")[1]); ///after
  minutes = minutes - 1;
  if (minutes <= 60) {
    $(".add-time").val() = hours …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

1
推荐指数
1
解决办法
872
查看次数

播放声音收到消息时

我想在接收消息时播放声音,所以我搜索它并找到了许多解决方案,但我找到的最简单的解决方案是

  <script>  
       $('body').append('<embed src="beep.mp3" autostart="true" hidden="true">');
  </script>
Run Code Online (Sandbox Code Playgroud)

但问题是它不能在Godzilla/IE中播放声音并在Chrome中播放.有没有办法解决这个问题,而无需添加任何额外的插件(Mozilla/JQuery).在Chrome中还有一个问题是,当声音播放时,主窗口的滚动条会从它的位置移动.我的主要问题是播放声音,因此优先考虑.任何人都知道它解决方案然后PLZ与我们分享谢谢.

javascript jquery

-1
推荐指数
1
解决办法
4539
查看次数